Skip to content

Commit

Permalink
[light-node] remove new node from the list to be deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
kroggen committed Jul 8, 2024
1 parent c73a903 commit a4a7621
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/trie/trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,13 +555,17 @@ func (s *Trie) leafHash(key, value, oldRoot []byte, batch [][]byte, iBatch, heig
}

// storeNode stores a batch and deletes the old node from cache
func (s *Trie) storeNode(batch [][]byte, h, oldRoot []byte, height int) {
if !bytes.Equal(h, oldRoot) {
func (s *Trie) storeNode(batch [][]byte, newRoot, oldRoot []byte, height int) {
if !bytes.Equal(newRoot, oldRoot) {
var node Hash
copy(node[:], h)
copy(node[:], newRoot)
// record new node
s.db.updatedMux.Lock()
s.db.updatedNodes[node] = batch
if s.lightNode {
// remove the new node from the list of nodes to be deleted
delete(s.db.deletedNodes, node)
}
s.db.updatedMux.Unlock()
// Cache the shortcut node if it's height is over CacheHeightLimit
if height >= s.CacheHeightLimit {
Expand Down

0 comments on commit a4a7621

Please sign in to comment.