code: func (b *BlockChain) BlockByHash(hash *chainhash.Hash) (*btcutil.Block, error) {
  	// Lookup the block hash in block index and ensure it is in the best
  	// chain.
  	node := b.index.LookupNode(hash)
  	if node == nil || !b.bestChain.Contains(node) {
  		str := fmt.Sprintf("block %s is not in the main chain", hash)
  		return nil, errNotInMainChain(str)
  	}
  
  	// Load the block from the database and return it.
  	var block *btcutil.Block
  	err := b.db.View(func(dbTx database.Tx) error {
  		var err error
  		block, err = dbFetchBlockByNode(dbTx, node)
  		return err
  	})
  	return block, err
  }
docs: // BlockByHash returns the block from the main chain with the given hash with
  // the appropriate chain height set.
  //
  // This function is safe for concurrent access.