Fix concurr. issues

This commit is contained in:
Manfred Karrer 2016-05-25 21:10:07 +02:00
parent 49815176bb
commit 3a61409b5c

View File

@ -61,6 +61,8 @@ import org.spongycastle.crypto.params.KeyParameter;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
@ -173,17 +175,25 @@ public class TradeManager {
private void initPendingTrades() {
Log.traceCall();
List<Trade> toAdd = new ArrayList<>();
List<Trade> toRemove = new ArrayList<>();
for (Trade trade : trades) {
trade.setStorage(tradableListStorage);
if (trade.isDepositFeePaid()) {
initTrade(trade, trade.getProcessModel().getUseSavingsWallet(), trade.getProcessModel().getFundsNeededForTrade());
trade.updateDepositTxFromWallet();
} else if (trade.isTakerFeePaid()) {
addTradeToFailedTrades(trade);
toAdd.add(trade);
} else {
removePreparedTrade(trade);
toRemove.add(trade);
}
}
for (Trade trade : toAdd) {
addTradeToFailedTrades(trade);
}
for (Trade trade : toRemove) {
removePreparedTrade(trade);
}
pendingTradesInitialized.set(true);
}