diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index 762fb9283e..8f8f219597 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -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 {