mirror of
https://github.com/boldsuck/haveno.git
synced 2024-12-22 20:19:21 +00:00
sync on wallet lock before checking if wallet is behind
This commit is contained in:
parent
3dfaa2fc52
commit
443c2f4cdb
1 changed files with 11 additions and 9 deletions
|
@ -2412,13 +2412,15 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
||||||
private void syncWallet(boolean pollWallet) {
|
private void syncWallet(boolean pollWallet) {
|
||||||
MoneroRpcConnection sourceConnection = xmrConnectionService.getConnection();
|
MoneroRpcConnection sourceConnection = xmrConnectionService.getConnection();
|
||||||
try {
|
try {
|
||||||
if (getWallet() == null) throw new RuntimeException("Cannot sync trade wallet because it doesn't exist for " + getClass().getSimpleName() + ", " + getId());
|
synchronized (walletLock) {
|
||||||
if (getWallet().getDaemonConnection() == null) throw new RuntimeException("Cannot sync trade wallet because it's not connected to a Monero daemon for " + getClass().getSimpleName() + ", " + getId());
|
if (getWallet() == null) throw new RuntimeException("Cannot sync trade wallet because it doesn't exist for " + getClass().getSimpleName() + ", " + getId());
|
||||||
if (isWalletBehind()) {
|
if (getWallet().getDaemonConnection() == null) throw new RuntimeException("Cannot sync trade wallet because it's not connected to a Monero daemon for " + getClass().getSimpleName() + ", " + getId());
|
||||||
log.info("Syncing wallet for {} {}", getClass().getSimpleName(), getShortId());
|
if (isWalletBehind()) {
|
||||||
long startTime = System.currentTimeMillis();
|
log.info("Syncing wallet for {} {}", getClass().getSimpleName(), getShortId());
|
||||||
syncWalletIfBehind();
|
long startTime = System.currentTimeMillis();
|
||||||
log.info("Done syncing wallet for {} {} in {} ms", getClass().getSimpleName(), getShortId(), System.currentTimeMillis() - startTime);
|
syncWalletIfBehind();
|
||||||
|
log.info("Done syncing wallet for {} {} in {} ms", getClass().getSimpleName(), getShortId(), System.currentTimeMillis() - startTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply tor after wallet synced depending on configuration
|
// apply tor after wallet synced depending on configuration
|
||||||
|
@ -2627,8 +2629,8 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void syncWalletIfBehind() {
|
private void syncWalletIfBehind() {
|
||||||
if (isWalletBehind()) {
|
synchronized (walletLock) {
|
||||||
synchronized (walletLock) {
|
if (isWalletBehind()) {
|
||||||
syncWithProgress();
|
syncWithProgress();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue