diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index 0cf03d61c..50fb76179 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -231,6 +231,9 @@ type BlockChain interface { // GetVMConfig is necessary for staged sync GetVMConfig() *vm.Config + + // Stop the import that is going on + Stop() } // New creates a new downloader to fetch hashes and blocks from remote peers. @@ -609,6 +612,7 @@ func (d *Downloader) Cancel() { // Terminate interrupts the downloader, canceling all pending operations. // The downloader cannot be reused after calling Terminate. func (d *Downloader) Terminate() { + d.blockchain.Stop() // Close the termination channel (make sure double close is allowed) d.quitLock.Lock() select { diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go index f75a66cf9..ba142586a 100644 --- a/eth/downloader/downloader_test.go +++ b/eth/downloader/downloader_test.go @@ -390,6 +390,9 @@ func (dl *downloadTester) GetHeader(common.Hash, uint64) *types.Header { panic("not implemented and should not be called") } +func (dl *downloadTester) Stop() { +} + type downloadTesterPeer struct { dl *downloadTester id string diff --git a/eth/downloader/stagedsync_test.go b/eth/downloader/stagedsync_test.go index 65c149812..0e1db2e29 100644 --- a/eth/downloader/stagedsync_test.go +++ b/eth/downloader/stagedsync_test.go @@ -275,6 +275,9 @@ func (st *stagedSyncTester) sync(id string, td *big.Int) error { return err } +func (st *stagedSyncTester) Stop() { +} + type stagedSyncTesterPeer struct { st *stagedSyncTester id string