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;
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
int maxAttempts = 10;
for (int i = 0; i < maxAttempts; i++) {
long startTimeMs = System.currentTimeMillis();
// repeatedly acquire trade lock to allow other threads to finish
for (int i = 0; i < 20; i++) {
synchronized (this) {
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);
}
@Override
public BigInteger getTotalTxFee() {
return BigInteger.valueOf(totalTxFee);
}