refactor: avoid overwriting blocks when clear-on-start is false #361
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.
Description
Refactors
chain_storeto stop overwriting blocks whenclear-on-startis false. After the first full sync, subsequent syncs run 2-3x faster because persistence now resumes fromlast_stored_block + 1.To prevent corrupt state when switching networks, this adds
handle_first_block, which compares the first block received fromcardano.block.availablewith the stored block and returns an error if the block bodies differ.Related Issue(s)
Speeds up development and testing for anything that depends on
chain_store. Implemented primarily to accelerate testing of the/addresses/{address}/utxosendpoint in #335.How was this tested?
last_stored_block + 1Checklist
Impact / Side effects
Major sync performance improvement (2-3x) after initial sync. Behavior unchanged when
clear-on-start = true.Reviewer notes / Areas to focus
All logic changes are fairly straight forward.