GetBodyRLP retrieves a block body in RLP encoding from the database by hash, caching it if found.
(hash common.Hash)
| 665 | // GetBodyRLP retrieves a block body in RLP encoding from the database by hash, |
| 666 | // caching it if found. |
| 667 | func (bc *BlockChain) GetBodyRLP(hash common.Hash) rlp.RawValue { |
| 668 | // Short circuit if the body's already in the cache, retrieve otherwise |
| 669 | if cached, ok := bc.bodyRLPCache.Get(hash); ok { |
| 670 | return cached.(rlp.RawValue) |
| 671 | } |
| 672 | number := bc.hc.GetBlockNumber(hash) |
| 673 | if number == nil { |
| 674 | return nil |
| 675 | } |
| 676 | body := rawdb.ReadBodyRLP(bc.db, hash, *number) |
| 677 | if len(body) == 0 { |
| 678 | return nil |
| 679 | } |
| 680 | // Cache the found body for next time and return |
| 681 | bc.bodyRLPCache.Add(hash, body) |
| 682 | return body |
| 683 | } |
| 684 | |
| 685 | // HasBlock checks if a block is fully present in the database or not. |
| 686 | func (bc *BlockChain) HasBlock(hash common.Hash, number uint64) bool { |
no test coverage detected