Pull initial chain compaction out of init() and into the syncer #2738
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.
We added a
chain.compact()
on startup in #2127 to ensure nodes that did not run 24/7 still had the opportunity to compact their local storage (like a laptop that is running only intermittently).This PR pulls this initial
chain.compact()
call out fromChain::init()
and into thesyncer
, specifically on initial transition toNoSync
.It never really belonged there as
Chain::init()
should not be responsible for going off and cleaning local storage up as it starts up.This postpones the compaction process to after the initial sync, rather than having it run before we start syncing.
Additionally we add a 60 block threshold to prevent a node triggering multiple chain compactions if restarted frequently (like we do during dev and testing).
This should make the node a bit more responsive initially and should allow a node to begin syncing a little quicker on startup.
Example where we skip chain compaction because we recently ran one -