From a259ae54e88322a42746025aad221fb7b27d95a1 Mon Sep 17 00:00:00 2001 From: Delweng Date: Wed, 23 Jul 2025 22:21:58 +0800 Subject: [PATCH] maintain the cache Signed-off-by: Delweng --- triedb/pathdb/history_index.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/triedb/pathdb/history_index.go b/triedb/pathdb/history_index.go index b35541badf..cfddefbe25 100644 --- a/triedb/pathdb/history_index.go +++ b/triedb/pathdb/history_index.go @@ -304,6 +304,9 @@ func (w *indexWriter) finish(batch ethdb.Batch) { for _, desc := range descList { buf = append(buf, desc.encode()...) } + if key := w.state.String(); historyIndexCache.Contains(key) { + historyIndexCache.Add(key, buf) + } if w.state.account { rawdb.WriteAccountHistoryIndex(batch, w.state.addressHash, buf) } else { @@ -420,6 +423,9 @@ func (d *indexDeleter) pop(id uint64) error { // // This function is safe to be called multiple times. func (d *indexDeleter) finish(batch ethdb.Batch) { + if key := d.state.String(); historyIndexCache.Contains(key) { + historyIndexCache.Remove(key) + } for _, id := range d.dropped { if d.state.account { rawdb.DeleteAccountHistoryIndexBlock(batch, d.state.addressHash, id)