mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
remove wait function from trie prefetcher. make close not remove fetchers. Fix stateless blockchain test-runner.
This commit is contained in:
parent
494ba791a1
commit
259f3e2b4e
3 changed files with 7 additions and 17 deletions
|
|
@ -921,13 +921,12 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
|
|||
prefetcher := s.prefetcher
|
||||
if s.prefetcher != nil {
|
||||
defer func() {
|
||||
s.prefetcher.wait()
|
||||
s.prefetcher.close()
|
||||
if s.witness != nil {
|
||||
// TODO: move read prefetcher logic into Commit?
|
||||
s.collectReadStorageAccessLists()
|
||||
s.collectReadAccountsAccessLists()
|
||||
}
|
||||
s.prefetcher.close()
|
||||
s.prefetcher = nil
|
||||
}()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,8 @@ func newTriePrefetcher(db Database, root common.Hash, namespace string) *triePre
|
|||
}
|
||||
|
||||
// close iterates over all the subfetchers, waits on any that were left spinning
|
||||
// and reports the stats to the metrics subsystem.
|
||||
// and reports the stats to the metrics subsystem. close should not be called
|
||||
// more than once on a triePrefetcher instance.
|
||||
func (p *triePrefetcher) close() {
|
||||
for _, fetcher := range p.fetchers {
|
||||
fetcher.wait() // safe to do multiple times
|
||||
|
|
@ -99,8 +100,6 @@ func (p *triePrefetcher) close() {
|
|||
}
|
||||
}
|
||||
}
|
||||
// Clear out all fetchers (will crash on a second call, deliberate)
|
||||
p.fetchers = nil
|
||||
}
|
||||
|
||||
// prefetch schedules a batch of trie items to prefetch.
|
||||
|
|
@ -210,14 +209,6 @@ func (sf *subfetcher) schedule(keys [][]byte) {
|
|||
}
|
||||
}
|
||||
|
||||
// wait instructs all subfetchers to finish their tasks
|
||||
// and stop receiving new requests.
|
||||
func (p *triePrefetcher) wait() {
|
||||
for _, fetcher := range p.fetchers {
|
||||
fetcher.wait()
|
||||
}
|
||||
}
|
||||
|
||||
// wait waits for the subfetcher to finish it's task. It is safe to call wait multiple
|
||||
// times but it is not thread safe.
|
||||
func (sf *subfetcher) wait() {
|
||||
|
|
|
|||
|
|
@ -194,21 +194,21 @@ func execBlockTestStateless(t *testing.T, bt *testMatcher, test *BlockTest) {
|
|||
tracer := logger.NewJSONLogger(logconfig, os.Stdout)
|
||||
_ = tracer
|
||||
|
||||
if err := bt.checkFailure(t, test.RunStateless(false, rawdb.HashScheme, nil)); err != nil {
|
||||
if err := bt.checkFailure(t, test.RunStateless(false, rawdb.HashScheme, nil, nil)); err != nil {
|
||||
t.Errorf("test in hash mode without snapshotter failed: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := bt.checkFailure(t, test.RunStateless(true, rawdb.HashScheme, nil)); err != nil {
|
||||
if err := bt.checkFailure(t, test.RunStateless(true, rawdb.HashScheme, nil, nil)); err != nil {
|
||||
t.Errorf("test in hash mode with snapshotter failed: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := bt.checkFailure(t, test.RunStateless(false, rawdb.PathScheme, nil)); err != nil {
|
||||
if err := bt.checkFailure(t, test.RunStateless(false, rawdb.PathScheme, nil, nil)); err != nil {
|
||||
t.Errorf("test in path mode without snapshotter failed: %v", err)
|
||||
return
|
||||
}
|
||||
if err := bt.checkFailure(t, test.RunStateless(true, rawdb.PathScheme, nil)); err != nil {
|
||||
if err := bt.checkFailure(t, test.RunStateless(true, rawdb.PathScheme, nil, nil)); err != nil {
|
||||
t.Errorf("test in path mode with snapshotter failed: %v", err)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue