mirror of
https://github.com/boldsuck/haveno.git
synced 2024-12-22 20:19:21 +00:00
use lock for importing multisig hex
This commit is contained in:
parent
ca7d596175
commit
d9a3feba8d
1 changed files with 16 additions and 13 deletions
|
@ -143,7 +143,8 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
||||||
private static final long DELETE_AFTER_NUM_BLOCKS = 2; // if deposit requested but not published
|
private static final long DELETE_AFTER_NUM_BLOCKS = 2; // if deposit requested but not published
|
||||||
private static final long EXTENDED_RPC_TIMEOUT = 600000; // 10 minutes
|
private static final long EXTENDED_RPC_TIMEOUT = 600000; // 10 minutes
|
||||||
private static final long DELETE_AFTER_MS = TradeProtocol.TRADE_STEP_TIMEOUT_SECONDS;
|
private static final long DELETE_AFTER_MS = TradeProtocol.TRADE_STEP_TIMEOUT_SECONDS;
|
||||||
private final Object pollLock = new Object();
|
protected final Object pollLock = new Object();
|
||||||
|
protected static final Object importMultisigLock = new Object();
|
||||||
private boolean pollInProgress;
|
private boolean pollInProgress;
|
||||||
private boolean restartInProgress;
|
private boolean restartInProgress;
|
||||||
private Subscription protocolErrorStateSubscription;
|
private Subscription protocolErrorStateSubscription;
|
||||||
|
@ -1066,18 +1067,20 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
||||||
public void importMultisigHex() {
|
public void importMultisigHex() {
|
||||||
synchronized (walletLock) {
|
synchronized (walletLock) {
|
||||||
synchronized (HavenoUtils.getDaemonLock()) { // lock on daemon because import calls full refresh
|
synchronized (HavenoUtils.getDaemonLock()) { // lock on daemon because import calls full refresh
|
||||||
for (int i = 0; i < TradeProtocol.MAX_ATTEMPTS; i++) {
|
synchronized (importMultisigLock) {
|
||||||
MoneroRpcConnection sourceConnection = xmrConnectionService.getConnection();
|
for (int i = 0; i < TradeProtocol.MAX_ATTEMPTS; i++) {
|
||||||
try {
|
MoneroRpcConnection sourceConnection = xmrConnectionService.getConnection();
|
||||||
doImportMultisigHex();
|
try {
|
||||||
break;
|
doImportMultisigHex();
|
||||||
} catch (IllegalArgumentException | IllegalStateException e) {
|
break;
|
||||||
throw e;
|
} catch (IllegalArgumentException | IllegalStateException e) {
|
||||||
} catch (Exception e) {
|
throw e;
|
||||||
log.warn("Failed to import multisig hex, tradeId={}, attempt={}/{}, error={}", getShortId(), i + 1, TradeProtocol.MAX_ATTEMPTS, e.getMessage());
|
} catch (Exception e) {
|
||||||
handleWalletError(e, sourceConnection);
|
log.warn("Failed to import multisig hex, tradeId={}, attempt={}/{}, error={}", getShortId(), i + 1, TradeProtocol.MAX_ATTEMPTS, e.getMessage());
|
||||||
if (i == TradeProtocol.MAX_ATTEMPTS - 1) throw e;
|
handleWalletError(e, sourceConnection);
|
||||||
HavenoUtils.waitFor(TradeProtocol.REPROCESS_DELAY_MS); // wait before retrying
|
if (i == TradeProtocol.MAX_ATTEMPTS - 1) throw e;
|
||||||
|
HavenoUtils.waitFor(TradeProtocol.REPROCESS_DELAY_MS); // wait before retrying
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue