Stop blockchain when terminating downloader (#574)

* Print

* Stop blockchain on Terminate

* Remove prints
This commit is contained in:
ledgerwatch 2020-05-25 08:19:08 +01:00 committed by GitHub
parent df28575420
commit 154b9a9ca2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 0 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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