mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-23 03:59:36 +00:00
fixes to persisted trades initialization
This commit is contained in:
parent
9f3b0c96c4
commit
5c814700fb
1 changed files with 27 additions and 13 deletions
|
@ -407,6 +407,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
||||||
Set<Runnable> tasks = new HashSet<Runnable>();
|
Set<Runnable> tasks = new HashSet<Runnable>();
|
||||||
Set<String> uids = new HashSet<String>();
|
Set<String> uids = new HashSet<String>();
|
||||||
Set<Trade> tradesToSkip = new HashSet<Trade>();
|
Set<Trade> tradesToSkip = new HashSet<Trade>();
|
||||||
|
Set<Trade> tradesToMaybeRemoveOnError = new HashSet<Trade>();
|
||||||
for (Trade trade : trades) {
|
for (Trade trade : trades) {
|
||||||
tasks.add(() -> {
|
tasks.add(() -> {
|
||||||
try {
|
try {
|
||||||
|
@ -423,9 +424,10 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
||||||
|
|
||||||
// remove trade if protocol didn't initialize
|
// remove trade if protocol didn't initialize
|
||||||
if (getOpenTradeByUid(trade.getUid()).isPresent() && !trade.isDepositsPublished()) {
|
if (getOpenTradeByUid(trade.getUid()).isPresent() && !trade.isDepositsPublished()) {
|
||||||
maybeRemoveTradeOnError(trade);
|
tradesToMaybeRemoveOnError.add(trade);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
log.warn("Error initializing {} {}: {}", trade.getClass().getSimpleName(), trade.getId(), e.getMessage());
|
log.warn("Error initializing {} {}: {}", trade.getClass().getSimpleName(), trade.getId(), e.getMessage());
|
||||||
trade.setInitError(e);
|
trade.setInitError(e);
|
||||||
}
|
}
|
||||||
|
@ -458,6 +460,11 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
||||||
EasyBind.subscribe(HavenoUtils.havenoSetup.getAppStartupState().applicationFullyInitializedProperty(), appInitialized -> {
|
EasyBind.subscribe(HavenoUtils.havenoSetup.getAppStartupState().applicationFullyInitializedProperty(), appInitialized -> {
|
||||||
if (!appInitialized) return;
|
if (!appInitialized) return;
|
||||||
|
|
||||||
|
// maybe remove trades on error
|
||||||
|
for (Trade trade : tradesToMaybeRemoveOnError) {
|
||||||
|
maybeRemoveTradeOnError(trade);
|
||||||
|
}
|
||||||
|
|
||||||
// thaw unreserved outputs
|
// thaw unreserved outputs
|
||||||
thawUnreservedOutputs();
|
thawUnreservedOutputs();
|
||||||
|
|
||||||
|
@ -468,8 +475,19 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
||||||
log.warn("Swapping pending {} entries at startup. offerId={}", addressEntry.getContext(), addressEntry.getOfferId());
|
log.warn("Swapping pending {} entries at startup. offerId={}", addressEntry.getContext(), addressEntry.getOfferId());
|
||||||
xmrWalletService.swapTradeEntryToAvailableEntry(addressEntry.getOfferId(), addressEntry.getContext());
|
xmrWalletService.swapTradeEntryToAvailableEntry(addressEntry.getOfferId(), addressEntry.getContext());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onTradesInitiailizedAndAppFullyInitialized();
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
onTradesInitiailizedAndAppFullyInitialized();
|
||||||
}
|
}
|
||||||
|
}).start();
|
||||||
|
|
||||||
|
// allow execution to start
|
||||||
|
GenUtils.waitFor(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onTradesInitiailizedAndAppFullyInitialized() {
|
||||||
|
|
||||||
// notify that persisted trades initialized
|
// notify that persisted trades initialized
|
||||||
persistedTradesInitialized.set(true);
|
persistedTradesInitialized.set(true);
|
||||||
|
@ -481,10 +499,6 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
||||||
String referralId = referralIdService.getOptionalReferralId().orElse(null);
|
String referralId = referralIdService.getOptionalReferralId().orElse(null);
|
||||||
boolean isTorNetworkNode = p2PService.getNetworkNode() instanceof TorNetworkNode;
|
boolean isTorNetworkNode = p2PService.getNetworkNode() instanceof TorNetworkNode;
|
||||||
tradeStatisticsManager.maybeRepublishTradeStatistics(nonFailedTrades, referralId, isTorNetworkNode);
|
tradeStatisticsManager.maybeRepublishTradeStatistics(nonFailedTrades, referralId, isTorNetworkNode);
|
||||||
}).start();
|
|
||||||
|
|
||||||
// allow execution to start
|
|
||||||
GenUtils.waitFor(100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initPersistedTrade(Trade trade) {
|
private void initPersistedTrade(Trade trade) {
|
||||||
|
|
Loading…
Reference in a new issue