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 authored Sep 18, 2023
1 parent fbb9020 commit 33c0b5d
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 33c0b5d

Please sign in to comment.