mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +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 inserts a batch of blocks into the local chain.
|
||||||
InsertChain(types.Blocks) (int, error)
|
InsertChain(types.Blocks) (int, error)
|
||||||
|
|
||||||
|
// StopInsert interrupts the inserting process.
|
||||||
|
StopInsert()
|
||||||
|
|
||||||
// InsertReceiptChain inserts a batch of blocks along with their receipts
|
// InsertReceiptChain inserts a batch of blocks along with their receipts
|
||||||
// into the local chain. Blocks older than the specified `ancientLimit`
|
// into the local chain. Blocks older than the specified `ancientLimit`
|
||||||
// are stored directly in the ancient store, while newer blocks are stored
|
// 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.
|
// Terminate interrupts the downloader, canceling all pending operations.
|
||||||
// The downloader cannot be reused after calling Terminate.
|
// The downloader cannot be reused after calling Terminate.
|
||||||
func (d *Downloader) 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)
|
// Close the termination channel (make sure double close is allowed)
|
||||||
d.quitLock.Lock()
|
d.quitLock.Lock()
|
||||||
select {
|
select {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue