From 42310a693769d6b7ecc73b3d117a3a6b9a95b7cd Mon Sep 17 00:00:00 2001 From: buddh0 Date: Tue, 24 Dec 2024 15:08:05 +0800 Subject: [PATCH] triedb/pathdb: fix copyNodeCache for asyncnodebuffer --- triedb/pathdb/asyncnodebuffer.go | 17 ++--------------- triedb/pathdb/disklayer.go | 3 --- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/triedb/pathdb/asyncnodebuffer.go b/triedb/pathdb/asyncnodebuffer.go index 4a858f321a..b4e9f76cd0 100644 --- a/triedb/pathdb/asyncnodebuffer.go +++ b/triedb/pathdb/asyncnodebuffer.go @@ -99,15 +99,6 @@ func (a *asyncnodebuffer) revertTo(db ethdb.KeyValueReader, nodes map[common.Has return a.current.revertTo(db, nodes, accounts, storages) } -// reset cleans up the disk cache. -func (a *asyncnodebuffer) reset() { - a.mux.Lock() - defer a.mux.Unlock() - - a.current.reset() - a.background.reset() -} - // empty returns an indicator if nodebuffer contains any state transition inside. func (a *asyncnodebuffer) empty() bool { a.mux.RLock() @@ -116,10 +107,6 @@ func (a *asyncnodebuffer) empty() bool { return a.current.empty() && a.background.empty() } -func (a *asyncnodebuffer) full() bool { - return a.current.full() -} - // flush persists the in-memory dirty trie node into the disk if the configured // memory threshold is reached. Note, all data must be written atomically. func (a *asyncnodebuffer) flush(db ethdb.KeyValueStore, freezer ethdb.AncientWriter, clean *fastcache.Cache, id uint64, force bool) error { @@ -142,7 +129,7 @@ func (a *asyncnodebuffer) flush(db ethdb.KeyValueStore, freezer ethdb.AncientWri } } - if !a.full() { + if !a.current.full() { return nil } @@ -284,7 +271,7 @@ func copyNodeCache(n *nodecache) *nodecache { if n == nil || n.buffer == nil { return nil } - nc := newNodeCache(int(n.limit), n.nodes, n.states, n.layers) + nc := newNodeCache(int(n.limit), nil, nil, n.layers) nc.immutable = atomic.LoadUint64(&n.immutable) for acc, subTree := range n.nodes.nodes { diff --git a/triedb/pathdb/disklayer.go b/triedb/pathdb/disklayer.go index 295478089e..209fdb9d98 100644 --- a/triedb/pathdb/disklayer.go +++ b/triedb/pathdb/disklayer.go @@ -58,9 +58,6 @@ type trienodebuffer interface { // memory threshold is reached. Note, all data must be written atomically. flush(db ethdb.KeyValueStore, freezer ethdb.AncientWriter, clean *fastcache.Cache, id uint64, force bool) error - // reset cleans up the disk cache. - reset() - // empty returns an indicator if trienodebuffer contains any state transition inside. empty() bool