Commit 7755aac3 authored by Adrian Sutton's avatar Adrian Sutton Committed by GitHub

op-program: Optimise block by header lookup (#13932)

We just requested the header by hash so can skip hashing the header to update the cache and just use the already known hash.
parent ef03df7e
...@@ -48,8 +48,9 @@ func (o *CanonicalBlockHeaderOracle) GetHeaderByNumber(n uint64) *types.Header { ...@@ -48,8 +48,9 @@ func (o *CanonicalBlockHeaderOracle) GetHeaderByNumber(n uint64) *types.Header {
h := o.earliestIndexedBlock h := o.earliestIndexedBlock
for h.Number.Uint64() > n { for h.Number.Uint64() > n {
h = o.blockByHashFn(h.ParentHash).Header() hash := h.ParentHash
o.hashByNum[h.Number.Uint64()] = h.Hash() h = o.blockByHashFn(hash).Header()
o.hashByNum[h.Number.Uint64()] = hash
} }
o.earliestIndexedBlock = h o.earliestIndexedBlock = h
return h return h
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment