MCPcopy Create free account
hub / github.com/CPChain/chain / GetBlockByHash

Method GetBlockByHash

core/blockchain.go:727–733  ·  view source on GitHub ↗

GetBlockByHash retrieves a block from the database by hash, caching it if found.

(hash common.Hash)

Source from the content-addressed store, hash-verified

725
726// GetBlockByHash retrieves a block from the database by hash, caching it if found.
727func (bc *BlockChain) GetBlockByHash(hash common.Hash) *types.Block {
728 number := bc.hc.GetBlockNumber(hash)
729 if number == nil {
730 return nil
731 }
732 return bc.GetBlock(hash, *number)
733}
734
735// GetBlockByNumber retrieves a block from the database by number, caching it
736// (associated with its hash) if found.

Callers 2

loadLastStateMethod · 0.95
FastSyncCommitHeadMethod · 0.95

Calls 2

GetBlockMethod · 0.95
GetBlockNumberMethod · 0.45

Tested by

no test coverage detected