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

Method GetBody

core/blockchain.go:646–663  ·  view source on GitHub ↗

GetBody retrieves a block body (transactions and uncles) from the database by hash, caching it if found.

(hash common.Hash)

Source from the content-addressed store, hash-verified

644// GetBody retrieves a block body (transactions and uncles) from the database by
645// hash, caching it if found.
646func (bc *BlockChain) GetBody(hash common.Hash) *types.Body {
647 // Short circuit if the body's already in the cache, retrieve otherwise
648 if cached, ok := bc.bodyCache.Get(hash); ok {
649 body := cached.(*types.Body)
650 return body
651 }
652 number := bc.hc.GetBlockNumber(hash)
653 if number == nil {
654 return nil
655 }
656 body := rawdb.ReadBody(bc.db, hash, *number)
657 if body == nil {
658 return nil
659 }
660 // Cache the found body for next time and return
661 bc.bodyCache.Add(hash, body)
662 return body
663}
664
665// GetBodyRLP retrieves a block body in RLP encoding from the database by hash,
666// caching it if found.

Callers

nothing calls this directly

Calls 3

GetMethod · 0.65
AddMethod · 0.65
GetBlockNumberMethod · 0.45

Tested by

no test coverage detected