瀏覽代碼

[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>
KeefeL 4 年之前
父節點
當前提交
797ba71c80
共有 2 個文件被更改,包括 6 次插入3 次删除
  1. 5 3
      core/block_validator.go
  2. 1 0
      core/state/statedb.go

+ 5 - 3
core/block_validator.go

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

+ 1 - 0
core/state/statedb.go

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