From 3de36509f0eca52af10b8a4fba4a480cacddd546 Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Thu, 9 Jan 2025 20:23:53 +0000 Subject: [PATCH] DaoSnapshot: Fix isParseBlockChainComplete field data race --- .../java/bisq/core/dao/state/DaoStateSnapshotService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/bisq/core/dao/state/DaoStateSnapshotService.java b/core/src/main/java/bisq/core/dao/state/DaoStateSnapshotService.java index edf2891ea3..6274a3dc12 100644 --- a/core/src/main/java/bisq/core/dao/state/DaoStateSnapshotService.java +++ b/core/src/main/java/bisq/core/dao/state/DaoStateSnapshotService.java @@ -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 heightsOfLastAppliedSnapshots = new ArrayList<>(); /////////////////////////////////////////////////////////////////////////////////////////// @@ -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); @@ -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.