Skip to content

Commit

Permalink
Add btc wallet chain height to footer info
Browse files Browse the repository at this point in the history
  • Loading branch information
chimp1984 committed Nov 5, 2020
1 parent 0c4ba90 commit 9bfdea1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions core/src/main/java/bisq/core/app/WalletAppSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import bisq.core.btc.setup.WalletsSetup;
import bisq.core.btc.wallet.WalletsManager;
import bisq.core.locale.Res;
import bisq.core.provider.fee.FeeService;
import bisq.core.offer.OpenOfferManager;
import bisq.core.provider.fee.FeeService;
import bisq.core.trade.TradeManager;
import bisq.core.user.Preferences;
import bisq.core.util.FormattingUtils;
Expand Down Expand Up @@ -111,26 +111,30 @@ void init(@Nullable Consumer<String> chainFileLockedExceptionHandler,

ObjectProperty<Throwable> walletServiceException = new SimpleObjectProperty<>();
btcInfoBinding = EasyBind.combine(walletsSetup.downloadPercentageProperty(),
walletsSetup.chainHeightProperty(),
feeService.feeUpdateCounterProperty(),
walletServiceException,
(downloadPercentage, feeUpdate, exception) -> {
(downloadPercentage, chainHeight, feeUpdate, exception) -> {
String result;
if (exception == null) {
double percentage = (double) downloadPercentage;
long fees = feeService.getTxFeePerByte().longValue();
btcSyncProgress.set(percentage);
int bestChainHeight = walletsSetup.getChain() != null ? walletsSetup.getChain().getBestChainHeight() : 0;
String chainHeightAsString = bestChainHeight > 0 ? " (" + bestChainHeight + ")" : "";
if (percentage == 1) {
String feeRate = Res.get("mainView.footer.btcFeeRate", fees);
result = Res.get("mainView.footer.btcInfo",
Res.get("mainView.footer.btcInfo.synchronizedWith"),
getBtcNetworkAsString() + " / " + feeRate);
getBtcNetworkAsString() + chainHeightAsString + " / " + feeRate);
getBtcSplashSyncIconId().set("image-connection-synced");

downloadCompleteHandler.run();
} else if (percentage > 0.0) {
result = Res.get("mainView.footer.btcInfo",
Res.get("mainView.footer.btcInfo.synchronizingWith"),
getBtcNetworkAsString() + ": " + FormattingUtils.formatToPercentWithSymbol(percentage));
getBtcNetworkAsString() + ": " + FormattingUtils.formatToPercentWithSymbol(percentage)) +
chainHeightAsString;
} else {
result = Res.get("mainView.footer.btcInfo",
Res.get("mainView.footer.btcInfo.connectingTo"),
Expand Down Expand Up @@ -259,6 +263,7 @@ void setRejectedTxErrorMessageHandler(Consumer<String> rejectedTxErrorMessageHan
}
});
}

private String getBtcNetworkAsString() {
String postFix;
if (config.ignoreLocalBtcNode)
Expand Down

0 comments on commit 9bfdea1

Please sign in to comment.