diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index 0cf03d61c27f397a36b36e106ceadd983a2fbc95..50fb76179a023cd207a19360146a4dcec034ce77 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 f75a66cf9f9d9d0aed73e00f09090b05700ba200..ba142586a05388ba0f73a3fb5a5ca3002bf6c5a5 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 65c149812defaa641d2f7edd220c27a2d6de09b3..0e1db2e29d1a1383b903939330c15b3e1f7aff0b 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