Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Tidy-up FastSyncState persistence #845

Merged

Conversation

ajsutton
Copy link
Contributor

PR description

Improves the way FastSyncState is stored and loaded, particularly how that's integrated into the fast sync download process.

PivotHeaderStorage has been changed to FastSyncStateStorage and now fully encapsulates loading and storing of FastSyncState rather than just a BlockHeader. I started out pushing this into FastSyncState but required making FastSyncState aware of the fast sync data directory which polluted it and made testing harder.

The persisted state is now loaded upfront by FastSynchronizer as part of determining if fast sync can be used and then passed into the FastSyncDownloader to start the download process. Previously it was reloaded by the selectPivotBlock step. This leads to some nice consistency in that every step of the download process takes a FastSyncState and returns a (potentially different) one.

Also simplified the constructors for FastSyncState, that led to a fair bit of noise in the change set sorry...

Allow fast sync to resume if chain head is not genesis but a fast sync is still in progress.
If present, use the stored pivot block header when restarting.
Extract the fast sync logic out of DefaultSynchronizer into it's own class.
…ate loading and storing of FastSyncState instances.
Copy link
Contributor

@mbaxter mbaxter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 🎉

try {
if (!isFastSyncInProgress()) {
return Optional.empty();
return FastSyncState.EMPTY_SYNC_STATE;
}
final BytesValue rlp = BytesValue.wrap(Files.toByteArray(pivotBlockHeaderFile));
return Optional.of(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look like this needs to be wrapped in an Optional now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@ajsutton ajsutton merged commit f2e05bb into PegaSysEng:master Feb 13, 2019
@ajsutton ajsutton deleted the synchronizer-checks-fast-sync-allowed branch February 13, 2019 20:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants