GetBody retrieves a block body (transactions and uncles) from the database by hash, caching it if found.
(hash common.Hash)
| 644 | // GetBody retrieves a block body (transactions and uncles) from the database by |
| 645 | // hash, caching it if found. |
| 646 | func (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. |
nothing calls this directly
no test coverage detected