added mutex to trie.tracer (#1007)

This commit is contained in:
Pratik Patil 2023-09-18 10:43:16 +05:30 committed by GitHub
parent fbb9020bec
commit 33c0b5dd69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,6 +21,7 @@ import (
"bytes"
"errors"
"fmt"
"sync"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
@ -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.
@ -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
}