eth: quick canceling block inserting when debug_setHead is invoked #32067
+23
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If Geth is engaged in a long-run block synchronization, such as a full syncing over a large number of blocks, invoking
debug_setHead
will causedownloader.Cancel
to wait for all fetchers to stop first.This can be time-consuming, particularly for the block processing thread.
To address this, we manually call
blockchain.StopInsert
to interrupt the blocking processing thread and allow it to exit immediately, and after that callblockchain.ResumeInsert
to resume the block downloading process.Additionally, we add a sanity check for the input block number of
debug_setHead
to ensure its validity.