Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit e56616b

Browse files
committed
Prevent early notification about all FastSync states
1 parent b880fe3 commit e56616b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

ethereumj-core/src/main/java/org/ethereum/sync/FastSyncManager.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ public void main() {
725725

726726
syncSecure();
727727

728-
listener.onSyncDone(EthereumListener.SyncState.SECURE);
728+
fireSyncDone(SECURE);
729729
case COMPLETE:
730730
if (origSyncStage == COMPLETE) {
731731
logger.info("FastSync: SECURE sync was completed prior to this run, proceeding with next stage...");
@@ -735,11 +735,7 @@ public void main() {
735735

736736
syncBlocksReceipts();
737737

738-
// prevent early switch to COMPLETE state
739-
syncManager.setSyncDoneType(EthereumListener.SyncState.COMPLETE);
740-
if (syncManager.isSyncDone()) {
741-
listener.onSyncDone(EthereumListener.SyncState.COMPLETE);
742-
}
738+
fireSyncDone(COMPLETE);
743739
}
744740
logger.info("FastSync: Full sync done.");
745741
} catch (InterruptedException ex) {
@@ -755,6 +751,14 @@ public void main() {
755751
}
756752
}
757753

754+
private void fireSyncDone(EthereumListener.SyncState state) {
755+
// prevent early state notification when sync is not yet done
756+
syncManager.setSyncDoneType(state);
757+
if (syncManager.isSyncDone()) {
758+
listener.onSyncDone(state);
759+
}
760+
}
761+
758762
public boolean isFastSyncInProgress() {
759763
return fastSyncInProgress;
760764
}

0 commit comments

Comments
 (0)