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

Method GetBlocksFromHash

core/blockchain.go:756–771  ·  view source on GitHub ↗

GetBlocksFromHash returns the block corresponding to hash and up to n-1 ancestors. [deprecated by eth/62]

(hash common.Hash, n int)

Source from the content-addressed store, hash-verified

754// GetBlocksFromHash returns the block corresponding to hash and up to n-1 ancestors.
755// [deprecated by eth/62]
756func (bc *BlockChain) GetBlocksFromHash(hash common.Hash, n int) (blocks []*types.Block) {
757 number := bc.hc.GetBlockNumber(hash)
758 if number == nil {
759 return nil
760 }
761 for i := 0; i < n; i++ {
762 block := bc.GetBlock(hash, *number)
763 if block == nil {
764 break
765 }
766 blocks = append(blocks, block)
767 hash = block.ParentHash()
768 *number--
769 }
770 return
771}
772
773// TrieNode retrieves a blob of data associated with a trie node (or code hash)
774// either from ephemeral in-memory cache, or from persistent storage.

Callers

nothing calls this directly

Calls 3

GetBlockMethod · 0.95
ParentHashMethod · 0.80
GetBlockNumberMethod · 0.45

Tested by

no test coverage detected