mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
core: use numberCache in HasHeader
numberCache has higher capacity, increasing the odds of finding the header without a database lookup.
This commit is contained in:
parent
d4486f0cb0
commit
1436f5111e
1 changed files with 1 additions and 1 deletions
|
|
@ -363,7 +363,7 @@ func (hc *HeaderChain) GetHeaderByHash(hash common.Hash) *types.Header {
|
||||||
|
|
||||||
// HasHeader checks if a block header is present in the database or not.
|
// HasHeader checks if a block header is present in the database or not.
|
||||||
func (hc *HeaderChain) HasHeader(hash common.Hash, number uint64) bool {
|
func (hc *HeaderChain) HasHeader(hash common.Hash, number uint64) bool {
|
||||||
if _, ok := hc.headerCache.Get(hash); ok {
|
if hc.numberCache.Contains(hash) || hc.headerCache.Contains(hash) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
ok, _ := hc.chainDb.Has(headerKey(hash, number))
|
ok, _ := hc.chainDb.Has(headerKey(hash, number))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue