From 31a53d15a74a59879ee0b451a250974948c71765 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Fri, 19 Dec 2025 12:10:50 +0100 Subject: [PATCH] core/blockchain: improve cache handling at reorg Signed-off-by: Csaba Kiraly --- core/blockchain.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/blockchain.go b/core/blockchain.go index c39201b5ae..f381447f1c 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -2573,6 +2573,8 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Header) error batch := bc.db.NewBatch() for _, tx := range types.HashDifference(deletedTxs, rebirthTxs) { rawdb.DeleteTxLookupEntry(batch, tx) + // Handle cache as well (new ones were added in writeHeadBlock). + bc.txOnChainCache.Remove(tx) } // 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 @@ -2593,7 +2595,6 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Header) error } // Reset the tx lookup cache to clear stale txlookup cache. bc.txLookupCache.Purge() - bc.txOnChainCache.Purge() // Release the tx-lookup lock after mutation. bc.txLookupLock.Unlock()