Skip to content

Commit 970fece

Browse files
Merge pull request #3290 from HenrikJannsen/small-fixes
Small fixes
2 parents f05def2 + 9f1b08c commit 970fece

File tree

3 files changed

+39
-15
lines changed

3 files changed

+39
-15
lines changed

i18n/src/main/resources/application.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ splash.applicationServiceState.slowStartup.deleteTor=Delete Tor directory and sh
1717
# suppress inspection "UnusedProperty"
1818
splash.applicationServiceState.INITIALIZE_APP=Starting Bisq
1919
# suppress inspection "UnusedProperty"
20-
splash.applicationServiceState.INITIALIZE_NETWORK=Initialize P2P network
20+
splash.applicationServiceState.INITIALIZE_NETWORK=Bootstrap to P2P network
2121
# suppress inspection "UnusedProperty"
2222
splash.applicationServiceState.INITIALIZE_WALLET=Initialize wallet
2323
# suppress inspection "UnusedProperty"

network/network/src/main/java/bisq/network/p2p/node/Node.java

+10-13
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
package bisq.network.p2p.node;
1919

2020

21+
import bisq.common.network.Address;
22+
import bisq.common.network.TransportConfig;
23+
import bisq.common.network.TransportType;
2124
import bisq.common.observable.Observable;
2225
import bisq.common.threading.ThreadName;
2326
import bisq.common.timer.Scheduler;
2427
import bisq.common.util.CompletableFutureUtils;
2528
import bisq.common.util.ExceptionUtil;
2629
import bisq.common.util.StringUtils;
2730
import bisq.network.NetworkService;
28-
import bisq.common.network.Address;
29-
import bisq.common.network.TransportConfig;
30-
import bisq.common.network.TransportType;
3131
import bisq.network.identity.NetworkId;
3232
import bisq.network.p2p.message.EnvelopePayloadMessage;
3333
import bisq.network.p2p.node.authorization.AuthorizationService;
@@ -201,9 +201,9 @@ public void initialize() {
201201
if (startingStateLatch.isPresent() && startingStateLatch.get().getCount() > 0) {
202202
try {
203203
log.info("Our node is still starting up. We block the calling thread until state is RUNNING or a throw and exception after a timeout. Node: {}", getNodeInfo());
204-
boolean success = startingStateLatch.get().await(120, TimeUnit.SECONDS); //hsUploadTimeout
204+
boolean success = startingStateLatch.get().await(120, TimeUnit.SECONDS);
205205
if (!success) {
206-
String errorMessage = "State did not change from STARTING to RUNNING in 120 sec. Node: " + getNodeInfo();
206+
String errorMessage = "We got called a repeated initialize. State has not change from STARTING to RUNNING in 120 sec. Node: " + getNodeInfo();
207207
log.warn(errorMessage);
208208
throw new RuntimeException(new TimeoutException(errorMessage));
209209
} else {
@@ -554,14 +554,11 @@ public void handleNetworkMessage(EnvelopePayloadMessage envelopePayloadMessage,
554554
if (findConnection(connection).isEmpty()) {
555555
// TODO for now we delay the shutdown call to not introduce a bigger change in behaviour.
556556
// We need to test more to see if that case happens and why, and if there might be valid listeners.
557-
log.warn("""
558-
We got handleNetworkMessage called from an orphaned connection which is not managed by our \
559-
outboundConnectionsByAddress or inboundConnectionsByAddress maps. \
560-
We close after a short delay that connection to avoid memory leaks. \
561-
We still notify listeners as its is unclear yet if there are valid listeners in that case.\
562-
563-
envelopePayloadMessage={}
564-
connection={}""",
557+
log.warn("We got handleNetworkMessage called from an orphaned connection which is not managed by our\n" +
558+
"outboundConnectionsByAddress or inboundConnectionsByAddress maps.\n" +
559+
"We close after a short delay that connection to avoid memory leaks.\n" +
560+
"We still notify listeners as its is unclear yet if there are valid listeners in that case.\n" +
561+
"envelopePayloadMessage={} connection={}",
565562
StringUtils.truncate(envelopePayloadMessage), connection);
566563
Scheduler.run(() -> connection.shutdown(CloseReason.ORPHANED_CONNECTION))
567564
.host(this)

support/src/main/java/bisq/support/mediation/MediationRequestService.java

+28-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import bisq.chat.bisq_easy.open_trades.BisqEasyOpenTradeChannelService;
2727
import bisq.common.application.Service;
2828
import bisq.common.observable.Pin;
29+
import bisq.common.observable.collection.CollectionObserver;
30+
import bisq.common.timer.Scheduler;
2931
import bisq.common.util.DateUtils;
3032
import bisq.contract.bisq_easy.BisqEasyContract;
3133
import bisq.i18n.Res;
@@ -65,6 +67,7 @@ public class MediationRequestService implements Service, ConfidentialMessageServ
6567
private final BannedUserService bannedUserService;
6668
private final Set<MediatorsResponse> pendingMediatorsResponseMessages = new CopyOnWriteArraySet<>();
6769
private Pin channeldPin;
70+
private Scheduler throttleUpdatesScheduler;
6871

6972
public MediationRequestService(NetworkService networkService,
7073
ChatService chatService,
@@ -98,6 +101,10 @@ public CompletableFuture<Boolean> shutdown() {
98101
channeldPin.unbind();
99102
channeldPin = null;
100103
}
104+
if (throttleUpdatesScheduler != null) {
105+
throttleUpdatesScheduler.stop();
106+
throttleUpdatesScheduler = null;
107+
}
101108
return CompletableFuture.completedFuture(true);
102109
}
103110

@@ -229,7 +236,27 @@ private void processMediationResponse(MediatorsResponse mediatorsResponse) {
229236
mediatorsResponse.getTradeId());
230237
pendingMediatorsResponseMessages.add(mediatorsResponse);
231238
if (channeldPin == null) {
232-
channeldPin = bisqEasyOpenTradeChannelService.getChannels().addObserver(this::maybeProcessPendingMediatorsResponseMessages);
239+
channeldPin = bisqEasyOpenTradeChannelService.getChannels().addObserver(new CollectionObserver<>() {
240+
@Override
241+
public void add(BisqEasyOpenTradeChannel element) {
242+
// Delay and ignore too frequent updates
243+
if (throttleUpdatesScheduler == null) {
244+
throttleUpdatesScheduler = Scheduler.run(() -> {
245+
maybeProcessPendingMediatorsResponseMessages();
246+
throttleUpdatesScheduler = null;
247+
})
248+
.after(1000);
249+
}
250+
}
251+
252+
@Override
253+
public void remove(Object element) {
254+
}
255+
256+
@Override
257+
public void clear() {
258+
}
259+
});
233260
}
234261
});
235262
}

0 commit comments

Comments
 (0)