Skip to content

Commit

Permalink
Merge branch 'haveno-dex:master' into restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
XMRZombie authored Feb 19, 2025
2 parents 38743f5 + b9381f7 commit 5f2b881
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 15 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ monerod1-local:
--log-level 0 \
--add-exclusive-node 127.0.0.1:48080 \
--add-exclusive-node 127.0.0.1:58080 \
--max-connections-per-ip 10 \
--rpc-access-control-origins http://localhost:8080 \
--fixed-difficulty 500 \
--disable-rpc-ban \
Expand All @@ -88,6 +89,7 @@ monerod2-local:
--confirm-external-bind \
--add-exclusive-node 127.0.0.1:28080 \
--add-exclusive-node 127.0.0.1:58080 \
--max-connections-per-ip 10 \
--rpc-access-control-origins http://localhost:8080 \
--fixed-difficulty 500 \
--disable-rpc-ban \
Expand All @@ -106,6 +108,7 @@ monerod3-local:
--confirm-external-bind \
--add-exclusive-node 127.0.0.1:28080 \
--add-exclusive-node 127.0.0.1:48080 \
--max-connections-per-ip 10 \
--rpc-access-control-origins http://localhost:8080 \
--fixed-difficulty 500 \
--disable-rpc-ban \
Expand Down
4 changes: 1 addition & 3 deletions core/src/main/java/haveno/core/api/CoreTradesService.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import haveno.core.support.traderchat.TradeChatSession;
import haveno.core.support.traderchat.TraderChatManager;
import haveno.core.trade.ClosedTradableManager;
import haveno.core.trade.Tradable;
import haveno.core.trade.Trade;
import haveno.core.trade.TradeManager;
import haveno.core.trade.TradeUtil;
Expand Down Expand Up @@ -223,8 +222,7 @@ private Optional<Trade> getOpenTrade(String tradeId) {
}

private Optional<Trade> getClosedTrade(String tradeId) {
Optional<Tradable> tradable = closedTradableManager.getTradeById(tradeId);
return tradable.filter((t) -> t instanceof Trade).map(value -> (Trade) value);
return closedTradableManager.getTradeById(tradeId);
}

List<Trade> getTrades() {
Expand Down
10 changes: 6 additions & 4 deletions core/src/main/java/haveno/core/support/SupportManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,12 @@ private void onAckMessage(AckMessage ackMessage) {
getAllChatMessages(ackMessage.getSourceId()).stream()
.filter(msg -> msg.getUid().equals(ackMessage.getSourceUid()))
.forEach(msg -> {
if (ackMessage.isSuccess())
msg.setAcknowledged(true);
else
msg.setAckError(ackMessage.getErrorMessage());
UserThread.execute(() -> {
if (ackMessage.isSuccess())
msg.setAcknowledged(true);
else
msg.setAckError(ackMessage.getErrorMessage());
});
});
requestPersistence();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ public Optional<Tradable> getTradableById(String id) {
}
}

public Optional<Tradable> getTradeById(String id) {
public Optional<Trade> getTradeById(String id) {
synchronized (closedTradables) {
return closedTradables.stream().filter(e -> e instanceof Trade && e.getId().equals(id)).findFirst();
return getClosedTrades().stream().filter(e -> e.getId().equals(id)).findFirst();
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/haveno/core/trade/TradeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ public List<Trade> getClosedTrades() {
}

public Optional<Trade> getClosedTrade(String tradeId) {
return closedTradableManager.getClosedTrades().stream().filter(e -> e.getId().equals(tradeId)).findFirst();
return closedTradableManager.getTradeById(tradeId);
}

public Optional<Trade> getFailedTrade(String tradeId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
public abstract class BuyerSendPaymentSentMessage extends SendMailboxMessageTask {
private ChangeListener<MessageState> listener;
private Timer timer;
private static final int MAX_RESEND_ATTEMPTS = 10;
private static final int MAX_RESEND_ATTEMPTS = 20;
private int delayInMin = 10;
private int resendCounter = 0;

Expand Down Expand Up @@ -198,7 +198,16 @@ private void tryToSendAgainLater() {
onMessageStateChange(processModel.getPaymentSentMessageStateProperty().get());
}

delayInMin = delayInMin * 2;
// first re-send is after 2 minutes, then increase the delay exponentially
if (resendCounter == 0) {
int shortDelay = 2;
log.info("We will send the message again to the peer after a delay of {} min.", shortDelay);
timer = UserThread.runAfter(this::run, shortDelay, TimeUnit.MINUTES);
} else {
log.info("We will send the message again to the peer after a delay of {} min.", delayInMin);
timer = UserThread.runAfter(this::run, delayInMin, TimeUnit.MINUTES);
delayInMin = (int) ((double) delayInMin * 1.5);
}
resendCounter++;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
@Slf4j
public abstract class SendDepositsConfirmedMessage extends SendMailboxMessageTask {
private Timer timer;
private static final int MAX_RESEND_ATTEMPTS = 10;
private static final int MAX_RESEND_ATTEMPTS = 20;
private int delayInMin = 10;
private int resendCounter = 0;

Expand Down Expand Up @@ -137,15 +137,15 @@ private void tryToSendAgainLater() {
timer.stop();
}

// first re-send is after 2 minutes, then double the delay each iteration
// first re-send is after 2 minutes, then increase the delay exponentially
if (resendCounter == 0) {
int shortDelay = 2;
log.info("We will send the message again to the peer after a delay of {} min.", shortDelay);
timer = UserThread.runAfter(this::run, shortDelay, TimeUnit.MINUTES);
} else {
log.info("We will send the message again to the peer after a delay of {} min.", delayInMin);
timer = UserThread.runAfter(this::run, delayInMin, TimeUnit.MINUTES);
delayInMin = delayInMin * 2;
delayInMin = (int) ((double) delayInMin * 1.5);
}
resendCounter++;
}
Expand Down

0 comments on commit 5f2b881

Please sign in to comment.