Skip to content

Commit

Permalink
DaoSnapshot: Fix isParseBlockChainComplete field data race
Browse files Browse the repository at this point in the history
  • Loading branch information
alvasw committed Jan 9, 2025
1 parent f5a0b69 commit 3de3650
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class DaoStateSnapshotService implements DaoSetupService, DaoStateListene
private Runnable resyncDaoStateFromResourcesHandler;
private int daoRequiresRestartHandlerAttempts = 0;
private final AtomicBoolean persistingBlockInProgress = new AtomicBoolean();
private boolean isParseBlockChainComplete;
private final AtomicBoolean isParseBlockChainComplete = new AtomicBoolean();
private final List<Integer> heightsOfLastAppliedSnapshots = new ArrayList<>();

///////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -156,7 +156,7 @@ public void onDaoStateChanged(Block block) {
// Otherwise, we do it only after the initial blockchain parsing is completed to not delay the parsing.
// In that case we get the missing hashes from the seed nodes. At any new block we do the hash calculation
// ourselves and therefore get back confidence that our DAO state is in sync with the network.
if (preferences.isUseFullModeDaoMonitor() || isParseBlockChainComplete) {
if (preferences.isUseFullModeDaoMonitor() || isParseBlockChainComplete.get()) {
// We need to execute first the daoStateMonitoringService.createHashFromBlock to get the hash created
daoStateMonitoringService.createHashFromBlock(block);
maybeCreateSnapshot(block);
Expand All @@ -168,7 +168,7 @@ public void onDaoStateChanged(Block block) {

@Override
public void onParseBlockChainComplete() {
isParseBlockChainComplete = true;
isParseBlockChainComplete.set(true);

// In case we have dao monitoring deactivated we create the snapshot after we are completed with parsing,
// and we got called back from daoStateMonitoringService once the hashes are created from peers data.
Expand Down

0 comments on commit 3de3650

Please sign in to comment.