func (b *BlockChain) blockLocatorFromHash(hash *chainhash.Hash) BlockLocator {
	locator := make(BlockLocator, 0, wire.MaxBlockLocatorsPerMsg)
	locator = append(locator, hash)
	if hash.IsEqual(b.chainParams.GenesisHash) {
		return locator
	}
	blockHeight := int32(-1)
	forkHeight := int32(-1)
	node, exists := b.index[*hash]
	if !exists {
		var height uint32
		err := b.db.View(func(dbTx database.Tx) error {
			var err error
			height, err = dbFetchHeightByHash(dbTx, hash)
			return err
		})
		if err != nil {
			return locator
		}
		blockHeight = int32(height)
	} else {
		blockHeight = int32(node.height)
		if !node.inMainChain {
			for n := node; n.parent != nil; n = n.parent {
				if n.inMainChain {
					forkHeight = int32(n.height)
					break
				}
			}
		}
	}
	_ = b.db.View(func(dbTx database.Tx) error {
		iterNode := node
		increment := int32(1)
		for len(locator) < wire.MaxBlockLocatorsPerMsg-1 {
			if len(locator) > 10 {
				increment *= 2
			}
			blockHeight -= increment
			if blockHeight < 1 {
				break
			}
			if forkHeight != -1 && blockHeight > forkHeight {
				for iterNode != nil && blockHeight > int32(iterNode.height) {
					iterNode = iterNode.parent
				}
				if iterNode != nil && int32(iterNode.height) == blockHeight {
					locator = append(locator, iterNode.hash)
				}
				continue
			}
			h, err := dbFetchHashByHeight(dbTx, uint32(blockHeight))
			if err != nil {
				log.Warnf("Lookup of known valid height failed %v",
					blockHeight)
				continue
			}
			locator = append(locator, h)
		}
		return nil
	})
	locator = append(locator, b.chainParams.GenesisHash)
	return locator
}
blockLocatorFromHash returns a block locator for the passed block hash.
See BlockLocator for details on the algotirhm used to create a block locator.

In addition to the general algorithm referenced above, there are a couple of
special cases which are handled:

- If the genesis hash is passed, there are no previous hashes to add and
therefore the block locator will only consist of the genesis hash
- If the passed hash is not currently known, the block locator will only
consist of the passed hash

This function MUST be called with the chain state lock held (for reads).
package blockchain
import (
	"github.com/bitgo/prova/chaincfg/chainhash"
	"github.com/bitgo/prova/database"
	"github.com/bitgo/prova/wire"
)
type BlockLocator []*chainhash.Hash