code: func (b *BlockChain) HeightToHashRange(startHeight int32,
  	endHash *chainhash.Hash, maxResults int) ([]chainhash.Hash, error) {
  
  	endNode := b.index.LookupNode(endHash)
  	if endNode == nil {
  		return nil, fmt.Errorf("no known block header with hash %v", endHash)
  	}
  	if !b.index.NodeStatus(endNode).KnownValid() {
  		return nil, fmt.Errorf("block %v is not yet validated", endHash)
  	}
  	endHeight := endNode.height
  
  	if startHeight < 0 {
  		return nil, fmt.Errorf("start height (%d) is below 0", startHeight)
  	}
  	if startHeight > endHeight {
  		return nil, fmt.Errorf("start height (%d) is past end height (%d)",
  			startHeight, endHeight)
  	}
  
  	resultsLength := int(endHeight - startHeight + 1)
  	if resultsLength > maxResults {
  		return nil, fmt.Errorf("number of results (%d) would exceed max (%d)",
  			resultsLength, maxResults)
  	}
  
  	// Walk backwards from endHeight to startHeight, collecting block hashes.
  	node := endNode
  	hashes := make([]chainhash.Hash, resultsLength)
  	for i := resultsLength - 1; i >= 0; i-- {
  		hashes[i] = node.hash
  		node = node.parent
  	}
  	return hashes, nil
  }
docs: // HeightToHashRange returns a range of block hashes for the given start height
  // and end hash, inclusive on both ends.  The hashes are for all blocks that are
  // ancestors of endHash with height greater than or equal to startHeight.  The
  // end hash must belong to a block that is known to be valid.
  //
  // This function is safe for concurrent access.