Skip to content

Commit

Permalink
added mutex to trie.tracer (#1007)
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikspatil024 committed Sep 20, 2023
1 parent 770f542 commit 40f4ac4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion trie/trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"bytes"
"errors"
"fmt"
"sync"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -48,7 +49,8 @@ type Trie struct {

// tracer is the tool to track the trie changes.
// It will be reset after each commit operation.
tracer *tracer
tracer *tracer
tracerMutex sync.Mutex
}

// newFlag returns the cache flag value for a newly created node.
Expand Down Expand Up @@ -605,7 +607,9 @@ func (t *Trie) resolveAndTrack(n hashNode, prefix []byte) (node, error) {
return nil, err
}

t.tracerMutex.Lock()
t.tracer.onRead(prefix, blob)
t.tracerMutex.Unlock()

return mustDecodeNode(n, blob), nil
}
Expand Down

0 comments on commit 40f4ac4

Please sign in to comment.