HeaderChain.GetTd¶
| Source (upstream pre-purge) | Current | |
|---|---|---|
| File | core/headerchain.go |
headerchain_pow.go |
| Symbol | HeaderChain.GetTd |
HeaderChain.GetTd |
| Ref | f4d53133f~1 |
etc/v1.17.3-full-node |
3-way merge — purge → getc ← upstream¶
pre-purge
↗// GetTd retrieves a block's total difficulty in the canonical chain from the
// database by hash and number, caching it if found.
func (hc *HeaderChain) GetTd(hash common.Hash, number uint64) *big.Int {
// Short circuit if the td's already in the cache, retrieve otherwise
if cached, ok := hc.tdCache.Get(hash); ok {
return cached
}
td := rawdb.ReadTd(hc.chainDb, hash, number)
if td == nil {
return nil
}
// Cache the found body for next time and return
hc.tdCache.Add(hash, td)
return td
}