|
83 | 83 | blockReorgAddMeter = metrics.NewRegisteredMeter("chain/reorg/add", nil) |
84 | 84 | blockReorgDropMeter = metrics.NewRegisteredMeter("chain/reorg/drop", nil) |
85 | 85 |
|
86 | | - blockPrefetchExecuteTimer = metrics.NewRegisteredTimer("chain/prefetch/executes", nil) |
87 | | - blockPrefetchInterruptMeter = metrics.NewRegisteredMeter("chain/prefetch/interrupts", nil) |
| 86 | + blockPrefetchExecuteTimer = metrics.NewRegisteredTimer("chain/prefetch/executes", nil) |
| 87 | + blockPrefetchInterruptMeter = metrics.NewRegisteredMeter("chain/prefetch/interrupts", nil) |
| 88 | + blockPrefetchTxsInvalidMeter = metrics.NewRegisteredMeter("chain/prefetch/txs/invalid", nil) |
| 89 | + blockPrefetchTxsValidMeter = metrics.NewRegisteredMeter("chain/prefetch/txs/valid", nil) |
88 | 90 |
|
89 | 91 | errInsertionInterrupted = errors.New("insertion is interrupted") |
90 | 92 | errChainStopped = errors.New("blockchain is stopped") |
@@ -1020,7 +1022,7 @@ func (bc *BlockChain) stopWithoutSaving() { |
1020 | 1022 |
|
1021 | 1023 | // Signal shutdown to all goroutines. |
1022 | 1024 | close(bc.quit) |
1023 | | - bc.StopInsert() |
| 1025 | + bc.InterruptInsert(true) |
1024 | 1026 |
|
1025 | 1027 | // Now wait for all chain modifications to end and persistent goroutines to exit. |
1026 | 1028 | // |
@@ -1102,11 +1104,15 @@ func (bc *BlockChain) Stop() { |
1102 | 1104 | log.Info("Blockchain stopped") |
1103 | 1105 | } |
1104 | 1106 |
|
1105 | | -// StopInsert interrupts all insertion methods, causing them to return |
1106 | | -// errInsertionInterrupted as soon as possible. Insertion is permanently disabled after |
1107 | | -// calling this method. |
1108 | | -func (bc *BlockChain) StopInsert() { |
1109 | | - bc.procInterrupt.Store(true) |
| 1107 | +// InterruptInsert interrupts all insertion methods, causing them to return |
| 1108 | +// errInsertionInterrupted as soon as possible, or resume the chain insertion |
| 1109 | +// if required. |
| 1110 | +func (bc *BlockChain) InterruptInsert(on bool) { |
| 1111 | + if on { |
| 1112 | + bc.procInterrupt.Store(true) |
| 1113 | + } else { |
| 1114 | + bc.procInterrupt.Store(false) |
| 1115 | + } |
1110 | 1116 | } |
1111 | 1117 |
|
1112 | 1118 | // insertStopped returns true after StopInsert has been called. |
|
0 commit comments