repeatedly acquire trade lock to allow other threads to finish

This commit is contained in:
woodser 2023-04-26 10:09:04 -04:00
parent 605253ef62
commit 332da7535d

View File

@ -1145,13 +1145,11 @@ public abstract class Trade implements Tradable, Model {
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());
// allow other threads to finish processing by acquiring trade locks until there's no delay // repeatedly acquire trade lock to allow other threads to finish
int maxAttempts = 10; for (int i = 0; i < 20; i++) {
for (int i = 0; i < maxAttempts; i++) {
long startTimeMs = System.currentTimeMillis();
synchronized (this) { synchronized (this) {
synchronized (walletLock) { synchronized (walletLock) {
if (System.currentTimeMillis() - startTimeMs <= 10 || isShutDown) break; if (isShutDown) break;
} }
} }
} }
@ -1626,6 +1624,7 @@ public abstract class Trade implements Tradable, Model {
return BigInteger.valueOf(takerFee); return BigInteger.valueOf(takerFee);
} }
@Override
public BigInteger getTotalTxFee() { public BigInteger getTotalTxFee() {
return BigInteger.valueOf(totalTxFee); return BigInteger.valueOf(totalTxFee);
} }