Skip to content

Commit

Permalink
Fixes #5882
Browse files Browse the repository at this point in the history
When syncing from genesis the number of blocks are limited so we get the
`onParseBlockCompleteAfterBatchProcessing` called each time when the received
 blocks are processed, and as we are not at wallet height we repeat requesting
 blocks. But the new check for the BTC recipient triggers a resync from resource call.
We add now a check that we do this check only once the wallet is synced and our
block height from dao state matches wallet blockheight.
  • Loading branch information
chimp1984 authored and ripcurlx committed Dec 6, 2021
1 parent e802e68 commit c34a019
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package bisq.core.dao.state;

import bisq.core.btc.setup.WalletsSetup;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.dao.DaoSetupService;
import bisq.core.dao.governance.param.Param;
import bisq.core.dao.monitoring.DaoStateMonitoringService;
Expand Down Expand Up @@ -63,6 +65,8 @@ public class DaoStateSnapshotService implements DaoSetupService, DaoStateListene
private final GenesisTxInfo genesisTxInfo;
private final DaoStateStorageService daoStateStorageService;
private final DaoStateMonitoringService daoStateMonitoringService;
private final WalletsSetup walletsSetup;
private final BsqWalletService bsqWalletService;
private final Preferences preferences;
private final Config config;
private final File storageDir;
Expand All @@ -88,13 +92,17 @@ public DaoStateSnapshotService(DaoStateService daoStateService,
GenesisTxInfo genesisTxInfo,
DaoStateStorageService daoStateStorageService,
DaoStateMonitoringService daoStateMonitoringService,
WalletsSetup walletsSetup,
BsqWalletService bsqWalletService,
Preferences preferences,
Config config,
@Named(Config.STORAGE_DIR) File storageDir) {
this.daoStateService = daoStateService;
this.genesisTxInfo = genesisTxInfo;
this.daoStateStorageService = daoStateStorageService;
this.daoStateMonitoringService = daoStateMonitoringService;
this.walletsSetup = walletsSetup;
this.bsqWalletService = bsqWalletService;
this.preferences = preferences;
this.config = config;
this.storageDir = storageDir;
Expand All @@ -121,7 +129,9 @@ public void start() {

@Override
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
if (config.baseCurrencyNetwork.isMainnet()) {
if (config.baseCurrencyNetwork.isMainnet() &&
walletsSetup.isDownloadComplete() &&
daoStateService.getChainHeight() == bsqWalletService.getBestChainHeight()) {
// In case the DAO state is invalid we might get an outdated RECIPIENT_BTC_ADDRESS. In that case we trigger
// a dao resync from resources.
String address = daoStateService.getParamValue(Param.RECIPIENT_BTC_ADDRESS, daoStateService.getChainHeight());
Expand Down

0 comments on commit c34a019

Please sign in to comment.