mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
eth: stop insert if terminate invoked
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
ff0f3c50e9
commit
538ea2dea1
1 changed files with 6 additions and 0 deletions
|
|
@ -199,6 +199,9 @@ type BlockChain interface {
|
|||
// InsertChain inserts a batch of blocks into the local chain.
|
||||
InsertChain(types.Blocks) (int, error)
|
||||
|
||||
// StopInsert interrupts the inserting process.
|
||||
StopInsert()
|
||||
|
||||
// InsertReceiptChain inserts a batch of blocks along with their receipts
|
||||
// into the local chain. Blocks older than the specified `ancientLimit`
|
||||
// are stored directly in the ancient store, while newer blocks are stored
|
||||
|
|
@ -634,6 +637,9 @@ func (d *Downloader) Cancel() {
|
|||
// Terminate interrupts the downloader, canceling all pending operations.
|
||||
// The downloader cannot be reused after calling Terminate.
|
||||
func (d *Downloader) Terminate() {
|
||||
// Signal to stop inserting in-flight blocks
|
||||
d.blockchain.StopInsert()
|
||||
|
||||
// Close the termination channel (make sure double close is allowed)
|
||||
d.quitLock.Lock()
|
||||
select {
|
||||
|
|
|
|||
Loading…
Reference in a new issue