-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add indication that BSQ transactions are not up to date
- Loading branch information
Showing
6 changed files
with
133 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
desktop/src/main/java/bisq/desktop/main/presentation/DaoPresentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package bisq.desktop.main.presentation; | ||
|
||
import bisq.core.btc.wallet.BsqWalletService; | ||
import bisq.core.btc.wallet.BtcWalletService; | ||
import bisq.core.dao.DaoFacade; | ||
import bisq.core.dao.state.DaoStateListener; | ||
import bisq.core.dao.state.DaoStateService; | ||
import bisq.core.dao.state.model.blockchain.Block; | ||
import bisq.core.locale.Res; | ||
|
||
import javax.inject.Inject; | ||
|
||
import javafx.beans.property.DoubleProperty; | ||
import javafx.beans.property.SimpleDoubleProperty; | ||
import javafx.beans.property.SimpleStringProperty; | ||
import javafx.beans.property.StringProperty; | ||
import javafx.beans.value.ChangeListener; | ||
|
||
import lombok.Getter; | ||
|
||
public class DaoPresentation implements DaoStateListener { | ||
|
||
private final BtcWalletService btcWalletService; | ||
private final DaoFacade daoFacade; | ||
private final BsqWalletService bsqWalletService; | ||
private final ChangeListener<Number> walletChainHeightListener; | ||
|
||
@Getter | ||
private final DoubleProperty bsqSyncProgress = new SimpleDoubleProperty(-1); | ||
@Getter | ||
private final StringProperty bsqInfo = new SimpleStringProperty(Res.get("mainView.footer.bsqInfo.initializing")); | ||
|
||
@Inject | ||
public DaoPresentation(BtcWalletService btcWalletService, | ||
BsqWalletService bsqWalletService, | ||
DaoStateService daoStateService, | ||
DaoFacade daoFacade) { | ||
|
||
this.btcWalletService = btcWalletService; | ||
this.bsqWalletService = bsqWalletService; | ||
this.daoFacade = daoFacade; | ||
|
||
walletChainHeightListener = (observable, oldValue, newValue) -> onUpdateAnyChainHeight(); | ||
|
||
this.btcWalletService.getChainHeightProperty().addListener(walletChainHeightListener); | ||
daoStateService.addBsqStateListener(this); | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
// Private | ||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
private void onUpdateAnyChainHeight() { | ||
final int bsqBlockChainHeight = daoFacade.getChainHeight(); | ||
final int bsqWalletChainHeight = bsqWalletService.getBestChainHeight(); | ||
if (bsqWalletChainHeight > 0) { | ||
final boolean synced = bsqWalletChainHeight == bsqBlockChainHeight; | ||
if (bsqBlockChainHeight != bsqWalletChainHeight) { | ||
bsqSyncProgress.set(-1); | ||
} else { | ||
bsqSyncProgress.set(0); | ||
} | ||
|
||
if (synced) { | ||
bsqInfo.set(""); | ||
} else { | ||
bsqInfo.set(Res.get("mainView.footer.bsqInfo.synchronizing")); | ||
} | ||
} else { | ||
bsqInfo.set(Res.get("mainView.footer.bsqInfo.synchronizing")); | ||
} | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
// DaoStateListener | ||
/////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
@Override | ||
public void onNewBlockHeight(int blockHeight) { | ||
|
||
} | ||
|
||
@Override | ||
public void onParseBlockChainComplete() { | ||
|
||
} | ||
|
||
@Override | ||
public void onParseTxsCompleteAfterBatchProcessing(Block block) { | ||
onUpdateAnyChainHeight(); | ||
} | ||
|
||
@Override | ||
public void onParseTxsComplete(Block block) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters