Skip to content

Commit

Permalink
Refactor: rearrange methods
Browse files Browse the repository at this point in the history
  • Loading branch information
chimp1984 committed Oct 3, 2020
1 parent 518b5bc commit c161cdc
Showing 1 changed file with 105 additions and 100 deletions.
205 changes: 105 additions & 100 deletions core/src/main/java/bisq/core/app/BisqSetup.java
Expand Up @@ -226,45 +226,6 @@ public BisqSetup(DomainInitialisation domainInitialisation,
this.appStartupState = appStartupState;
}


///////////////////////////////////////////////////////////////////////////////////////////
// Setup
///////////////////////////////////////////////////////////////////////////////////////////

public void addBisqSetupListener(BisqSetupListener listener) {
bisqSetupListeners.add(listener);
}

public void start() {
maybeReSyncSPVChain();
maybeShowTac(this::step2);
}

private void step2() {
torSetup.cleanupTorFiles();
readMapsFromResources(this::step3);
checkForCorrectOSArchitecture();
checkOSXVersion();
checkIfRunningOnQubesOS();
}

private void step3() {
startP2pNetworkAndWallet(this::step4);
}

private void step4() {
initDomainServices();

bisqSetupListeners.forEach(BisqSetupListener::onSetupComplete);

// We set that after calling the setupCompleteHandler to not trigger a popup from the dev dummy accounts
// in MainViewModel
maybeShowSecurityRecommendation();
maybeShowLocalhostRunningInfo();
maybeShowAccountSigningStateInfo();
}


///////////////////////////////////////////////////////////////////////////////////////////
// API
///////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -289,58 +250,45 @@ public void displayAlertIfPresent(Alert alert, boolean openNewVersionPopup) {


///////////////////////////////////////////////////////////////////////////////////////////
// Getters
// Main startup tasks
///////////////////////////////////////////////////////////////////////////////////////////

// Wallet
public StringProperty getBtcInfo() {
return walletAppSetup.getBtcInfo();
}

public DoubleProperty getBtcSyncProgress() {
return walletAppSetup.getBtcSyncProgress();
}

public StringProperty getWalletServiceErrorMsg() {
return walletAppSetup.getWalletServiceErrorMsg();
}

public StringProperty getBtcSplashSyncIconId() {
return walletAppSetup.getBtcSplashSyncIconId();
}

public BooleanProperty getUseTorForBTC() {
return walletAppSetup.getUseTorForBTC();
public void addBisqSetupListener(BisqSetupListener listener) {
bisqSetupListeners.add(listener);
}

// P2P
public StringProperty getP2PNetworkInfo() {
return p2PNetworkSetup.getP2PNetworkInfo();
public void start() {
maybeReSyncSPVChain();
maybeShowTac(this::step2);
}

public BooleanProperty getSplashP2PNetworkAnimationVisible() {
return p2PNetworkSetup.getSplashP2PNetworkAnimationVisible();
private void step2() {
torSetup.cleanupTorFiles();
readMapsFromResources(this::step3);
checkForCorrectOSArchitecture();
checkOSXVersion();
checkIfRunningOnQubesOS();
}

public StringProperty getP2pNetworkWarnMsg() {
return p2PNetworkSetup.getP2pNetworkWarnMsg();
private void step3() {
startP2pNetworkAndWallet(this::step4);
}

public StringProperty getP2PNetworkIconId() {
return p2PNetworkSetup.getP2PNetworkIconId();
}
private void step4() {
initDomainServices();

public BooleanProperty getUpdatedDataReceived() {
return p2PNetworkSetup.getUpdatedDataReceived();
}
bisqSetupListeners.forEach(BisqSetupListener::onSetupComplete);

public StringProperty getP2pNetworkLabelId() {
return p2PNetworkSetup.getP2pNetworkLabelId();
// We set that after calling the setupCompleteHandler to not trigger a popup from the dev dummy accounts
// in MainViewModel
maybeShowSecurityRecommendation();
maybeShowLocalhostRunningInfo();
maybeShowAccountSigningStateInfo();
}


///////////////////////////////////////////////////////////////////////////////////////////
// Private
// Sub tasks
///////////////////////////////////////////////////////////////////////////////////////////

private void maybeReSyncSPVChain() {
Expand Down Expand Up @@ -468,6 +416,35 @@ private void initWallet() {
() -> walletInitialized.set(true));
}

private void initDomainServices() {
log.info("initDomainServices");

domainInitialisation.initDomainServices(rejectedTxErrorMessageHandler,
displayPrivateNotificationHandler,
daoErrorMessageHandler,
daoWarnMessageHandler,
filterWarningHandler,
voteResultExceptionHandler,
revolutAccountsUpdateHandler);

if (walletsSetup.downloadPercentageProperty().get() == 1) {
checkForLockedUpFunds();
checkForInvalidMakerFeeTxs();
}

alertManager.alertMessageProperty().addListener((observable, oldValue, newValue) ->
displayAlertIfPresent(newValue, false));
displayAlertIfPresent(alertManager.alertMessageProperty().get(), false);

allBasicServicesInitialized = true;

appStartupState.onDomainServicesInitialized();
}


///////////////////////////////////////////////////////////////////////////////////////////
// Utils
///////////////////////////////////////////////////////////////////////////////////////////

private void checkForLockedUpFunds() {
// We check if there are locked up funds in failed or closed trades
Expand Down Expand Up @@ -548,31 +525,6 @@ private void checkIfRunningOnQubesOS() {
}
}

private void initDomainServices() {
log.info("initDomainServices");

domainInitialisation.initDomainServices(rejectedTxErrorMessageHandler,
displayPrivateNotificationHandler,
daoErrorMessageHandler,
daoWarnMessageHandler,
filterWarningHandler,
voteResultExceptionHandler,
revolutAccountsUpdateHandler);

if (walletsSetup.downloadPercentageProperty().get() == 1) {
checkForLockedUpFunds();
checkForInvalidMakerFeeTxs();
}

alertManager.alertMessageProperty().addListener((observable, oldValue, newValue) ->
displayAlertIfPresent(newValue, false));
displayAlertIfPresent(alertManager.alertMessageProperty().get(), false);

allBasicServicesInitialized = true;

appStartupState.onDomainServicesInitialized();
}

private void maybeShowSecurityRecommendation() {
String key = "remindPasswordAndBackup";
user.getPaymentAccountsAsObservable().addListener((SetChangeListener<PaymentAccount>) change -> {
Expand Down Expand Up @@ -641,4 +593,57 @@ private void maybeTriggerDisplayHandler(String key, Consumer<String> displayHand
displayHandler.accept(key);
}
}


///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////

// Wallet
public StringProperty getBtcInfo() {
return walletAppSetup.getBtcInfo();
}

public DoubleProperty getBtcSyncProgress() {
return walletAppSetup.getBtcSyncProgress();
}

public StringProperty getWalletServiceErrorMsg() {
return walletAppSetup.getWalletServiceErrorMsg();
}

public StringProperty getBtcSplashSyncIconId() {
return walletAppSetup.getBtcSplashSyncIconId();
}

public BooleanProperty getUseTorForBTC() {
return walletAppSetup.getUseTorForBTC();
}

// P2P
public StringProperty getP2PNetworkInfo() {
return p2PNetworkSetup.getP2PNetworkInfo();
}

public BooleanProperty getSplashP2PNetworkAnimationVisible() {
return p2PNetworkSetup.getSplashP2PNetworkAnimationVisible();
}

public StringProperty getP2pNetworkWarnMsg() {
return p2PNetworkSetup.getP2pNetworkWarnMsg();
}

public StringProperty getP2PNetworkIconId() {
return p2PNetworkSetup.getP2PNetworkIconId();
}

public BooleanProperty getUpdatedDataReceived() {
return p2PNetworkSetup.getUpdatedDataReceived();
}

public StringProperty getP2pNetworkLabelId() {
return p2PNetworkSetup.getP2pNetworkLabelId();
}


}

0 comments on commit c161cdc

Please sign in to comment.