Skip to content

Commit

Permalink
triedb/pathdb: fix copyNodeCache for asyncnodebuffer (#2824)
Browse files Browse the repository at this point in the history
  • Loading branch information
buddh0 authored Dec 25, 2024
1 parent b6e1d5f commit 9b0130f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
17 changes: 2 additions & 15 deletions triedb/pathdb/asyncnodebuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 {
Expand All @@ -142,7 +129,7 @@ func (a *asyncnodebuffer) flush(db ethdb.KeyValueStore, freezer ethdb.AncientWri
}
}

if !a.full() {
if !a.current.full() {
return nil
}

Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 0 additions & 3 deletions triedb/pathdb/disklayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 9b0130f

Please sign in to comment.