GetHeader retrieves a block header from the database by hash and number, caching it if found.
(hash common.Hash, number uint64)
| 342 | // GetHeader retrieves a block header from the database by hash and number, |
| 343 | // caching it if found. |
| 344 | func (hc *HeaderChain) GetHeader(hash common.Hash, number uint64) *types.Header { |
| 345 | // Short circuit if the header's already in the cache, retrieve otherwise |
| 346 | if header, ok := hc.headerCache.Get(hash); ok { |
| 347 | return header.(*types.Header) |
| 348 | } |
| 349 | header := rawdb.ReadHeader(hc.chainDb, hash, number) |
| 350 | if header == nil { |
| 351 | return nil |
| 352 | } |
| 353 | // Cache the found header for next time and return |
| 354 | hc.headerCache.Add(hash, header) |
| 355 | return header |
| 356 | } |
| 357 | |
| 358 | // GetHeaderByHash retrieves a block header from the database by hash, caching it if |
| 359 | // found. |
no test coverage detected