[R4R]fix prefetcher related bugs (#491)

* fix goroutine leak in prefetcher

Signed-off-by: Keefe-Liu <bianze.kernel@gmail.com>

* wait all goroutine done to avoid prefetcher close panic

Signed-off-by: Keefe-Liu <bianze.kernel@gmail.com>
This commit is contained in:
KeefeL 2021-11-01 14:55:20 +08:00 committed by GitHub
parent 98c4e81643
commit 797ba71c80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

@ -144,13 +144,15 @@ func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateD
validateRes <- tmpFunc()
}()
}
var err error
for i := 0; i < len(validateFuns); i++ {
r := <-validateRes
if r != nil {
return r
if r != nil && err == nil {
err = r
}
}
return nil
return err
}
// CalcGasLimit computes the gas limit of the next block after parent. It aims

@ -958,6 +958,7 @@ func (s *StateDB) Finalise(deleteEmptyObjects bool) {
// goes into transaction receipts.
func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
if s.lightProcessed {
s.StopPrefetcher()
return s.trie.Hash()
}
// Finalise all the dirty storage states and write them into the tries