mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-01-22 02:34:57 +00:00
synchronize wallet poll and stop polling on shut down started
This commit is contained in:
parent
fd0bf23867
commit
51d5f0e1d3
1 changed files with 79 additions and 74 deletions
|
@ -22,6 +22,7 @@ import com.google.protobuf.ByteString;
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
|
|
||||||
import haveno.common.UserThread;
|
import haveno.common.UserThread;
|
||||||
|
import haveno.common.config.Config;
|
||||||
import haveno.common.crypto.Encryption;
|
import haveno.common.crypto.Encryption;
|
||||||
import haveno.common.crypto.PubKeyRing;
|
import haveno.common.crypto.PubKeyRing;
|
||||||
import haveno.common.proto.ProtoUtil;
|
import haveno.common.proto.ProtoUtil;
|
||||||
|
@ -1122,6 +1123,7 @@ public abstract class Trade implements Tradable, Model {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onShutDownStarted() {
|
public void onShutDownStarted() {
|
||||||
|
stopPolling();
|
||||||
isShutDownStarted = true;
|
isShutDownStarted = true;
|
||||||
if (wallet != null) log.info("{} {} preparing for shut down", getClass().getSimpleName(), getId());
|
if (wallet != null) log.info("{} {} preparing for shut down", getClass().getSimpleName(), getId());
|
||||||
|
|
||||||
|
@ -1780,6 +1782,7 @@ public abstract class Trade implements Tradable, Model {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateWalletRefreshPeriod() {
|
public void updateWalletRefreshPeriod() {
|
||||||
|
if (isShutDownStarted) return;
|
||||||
setWalletRefreshPeriod(getWalletRefreshPeriod());
|
setWalletRefreshPeriod(getWalletRefreshPeriod());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1824,13 +1827,14 @@ public abstract class Trade implements Tradable, Model {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pollWallet() {
|
private void pollWallet() {
|
||||||
|
synchronized (walletLock) {
|
||||||
MoneroWallet wallet = getWallet();
|
MoneroWallet wallet = getWallet();
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// check if wallet's height is less than daemon's
|
// log warning if wallet is too far behind daemon
|
||||||
MoneroDaemonInfo lastInfo = xmrWalletService.getConnectionsService().getLastInfo();
|
MoneroDaemonInfo lastInfo = xmrWalletService.getConnectionsService().getLastInfo();
|
||||||
if (lastInfo != null && wallet.getHeight() < lastInfo.getHeight() - 2) {
|
if (!Config.baseCurrencyNetwork().isTestnet() && isDepositsPublished() && lastInfo != null && wallet.getHeight() < lastInfo.getHeight() - 3) {
|
||||||
log.warn("Daemon's height is more than 2 blocks ahead of wallet's height; daemon height={}, wallet height={}, tradeId={}", lastInfo.getHeight(), wallet.getHeight(), getShortId());
|
log.warn("Wallet is more than 3 blocks behind monerod for {} {}, wallet height={}, monerod height={},", getClass().getSimpleName(), getShortId(), lastInfo.getHeight(), wallet.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip if either deposit tx id is unknown
|
// skip if either deposit tx id is unknown
|
||||||
|
@ -1912,6 +1916,7 @@ public abstract class Trade implements Tradable, Model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private long getWalletRefreshPeriod() {
|
private long getWalletRefreshPeriod() {
|
||||||
if (isIdling()) return IDLE_SYNC_PERIOD_MS;
|
if (isIdling()) return IDLE_SYNC_PERIOD_MS;
|
||||||
|
|
Loading…
Reference in a new issue