From 064315d6b3cc327d300208f157e761ed2b767081 Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Mon, 29 Jan 2024 14:34:53 +0800 Subject: [PATCH] core: reset txlookup cache if reorg happens --- core/blockchain.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 8ead80c253..24f09983b1 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -2209,10 +2209,9 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Block) error { for _, tx := range diffs { rawdb.DeleteTxLookupEntry(indexesBatch, tx) } - // Reset the tx lookup cache in case some indexes are removed. - if len(diffs) > 0 { - bc.txLookupCache.Purge() - } + // Reset the tx lookup cache in case to clear stale txlookups. + bc.txLookupCache.Purge() + // Delete all hash markers that are not part of the new canonical chain. // Because the reorg function does not handle new chain head, all hash // markers greater than or equal to new chain head should be deleted.