* 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>
@@ -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