skip reset address entries when failed trade is scheduled for deletion
This commit is contained in:
parent
8b1d2aa203
commit
bf97fbc7ea
2 changed files with 14 additions and 1 deletions
|
@ -923,8 +923,8 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
||||||
requestPersistence();
|
requestPersistence();
|
||||||
}, errorMessage -> {
|
}, errorMessage -> {
|
||||||
log.warn("Taker error during trade initialization: " + errorMessage);
|
log.warn("Taker error during trade initialization: " + errorMessage);
|
||||||
xmrWalletService.resetAddressEntriesForOpenOffer(trade.getId()); // TODO: move to maybe remove on error
|
|
||||||
trade.onProtocolError();
|
trade.onProtocolError();
|
||||||
|
xmrWalletService.resetAddressEntriesForOpenOffer(trade.getId()); // TODO: move this into protocol error handling
|
||||||
errorMessageHandler.handleErrorMessage(errorMessage);
|
errorMessageHandler.handleErrorMessage(errorMessage);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1285,6 +1285,12 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasFailedScheduledTrade(String offerId) {
|
||||||
|
synchronized (failedTradesManager) {
|
||||||
|
return failedTradesManager.getTradeById(offerId).isPresent() && failedTradesManager.getTradeById(offerId).get().isProtocolErrorHandlingScheduled();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Optional<Trade> getOpenTradeByUid(String tradeUid) {
|
public Optional<Trade> getOpenTradeByUid(String tradeUid) {
|
||||||
synchronized (tradableList) {
|
synchronized (tradableList) {
|
||||||
return tradableList.stream().filter(e -> e.getUid().equals(tradeUid)).findFirst();
|
return tradableList.stream().filter(e -> e.getUid().equals(tradeUid)).findFirst();
|
||||||
|
|
|
@ -1016,6 +1016,13 @@ public class XmrWalletService extends XmrWalletBase {
|
||||||
|
|
||||||
public synchronized void resetAddressEntriesForOpenOffer(String offerId) {
|
public synchronized void resetAddressEntriesForOpenOffer(String offerId) {
|
||||||
log.info("resetAddressEntriesForOpenOffer offerId={}", offerId);
|
log.info("resetAddressEntriesForOpenOffer offerId={}", offerId);
|
||||||
|
|
||||||
|
// skip if failed trade is scheduled for processing // TODO: do not call this function in this case?
|
||||||
|
if (tradeManager.hasFailedScheduledTrade(offerId)) {
|
||||||
|
log.warn("Refusing to reset address entries because trade is scheduled for deletion with offerId={}", offerId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
swapAddressEntryToAvailable(offerId, XmrAddressEntry.Context.OFFER_FUNDING);
|
swapAddressEntryToAvailable(offerId, XmrAddressEntry.Context.OFFER_FUNDING);
|
||||||
|
|
||||||
// swap trade payout to available if applicable
|
// swap trade payout to available if applicable
|
||||||
|
|
Loading…
Reference in a new issue