mirror of
https://github.com/boldsuck/haveno.git
synced 2024-12-22 20:19:21 +00:00
skip wallet polls if daemon not synced (#1080)
This commit is contained in:
parent
c3b93b6e75
commit
1debdde33e
2 changed files with 10 additions and 2 deletions
|
@ -2404,8 +2404,10 @@ public abstract class Trade implements Tradable, Model {
|
|||
// skip if deposit txs unknown or not requested
|
||||
if (processModel.getMaker().getDepositTxHash() == null || processModel.getTaker().getDepositTxHash() == null || !isDepositRequested()) return;
|
||||
|
||||
// skip if daemon not synced
|
||||
if (xmrConnectionService.getTargetHeight() == null || !xmrConnectionService.isSyncedWithinTolerance()) return;
|
||||
|
||||
// sync if wallet too far behind daemon
|
||||
if (xmrConnectionService.getTargetHeight() == null) return;
|
||||
if (walletHeight.get() < xmrConnectionService.getTargetHeight() - SYNC_EVERY_NUM_BLOCKS) syncWallet(false);
|
||||
|
||||
// update deposit txs
|
||||
|
|
|
@ -1803,12 +1803,18 @@ public class XmrWalletService {
|
|||
pollInProgress = true;
|
||||
try {
|
||||
|
||||
// switch to best connection if daemon is too far behind
|
||||
// skip if daemon not synced
|
||||
MoneroDaemonInfo lastInfo = xmrConnectionService.getLastInfo();
|
||||
if (lastInfo == null) {
|
||||
log.warn("Last daemon info is null");
|
||||
return;
|
||||
}
|
||||
if (!xmrConnectionService.isSyncedWithinTolerance()) {
|
||||
log.warn("Monero daemon is not synced within tolerance, height={}, targetHeight={}", xmrConnectionService.chainHeightProperty().get(), xmrConnectionService.getTargetHeight());
|
||||
return;
|
||||
}
|
||||
|
||||
// switch to best connection if wallet is too far behind
|
||||
if (wasWalletSynced && walletHeight.get() < xmrConnectionService.getTargetHeight() - NUM_BLOCKS_BEHIND_TOLERANCE && !Config.baseCurrencyNetwork().isTestnet()) {
|
||||
log.warn("Updating connection because main wallet is {} blocks behind monerod, wallet height={}, monerod height={}", xmrConnectionService.getTargetHeight() - walletHeight.get(), walletHeight.get(), lastInfo.getHeight());
|
||||
xmrConnectionService.switchToBestConnection();
|
||||
|
|
Loading…
Reference in a new issue