Skip to content

Commit

Permalink
[core] fix cache introduced by getHashByNumber (harmony-one#3814)
Browse files Browse the repository at this point in the history
  • Loading branch information
JackyWYX committed Jul 7, 2021
1 parent ab5be8f commit 7b0f6ac
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/headerchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,9 @@ func (hc *HeaderChain) getHashByNumber(number uint64) common.Hash {
return hash.(common.Hash)
}
hash := rawdb.ReadCanonicalHash(hc.chainDb, number)
hc.canonicalCache.Add(number, hash)
if hash != (common.Hash{}) {
hc.canonicalCache.Add(number, hash)
}
return hash
}

Expand Down

0 comments on commit 7b0f6ac

Please sign in to comment.