mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Shut down if more then 1 all connections lost events
This commit is contained in:
parent
1b7c1ce49a
commit
2486bd512f
@ -22,7 +22,9 @@ import bisq.core.app.misc.ModuleForAppWithP2p;
|
||||
|
||||
import bisq.network.p2p.P2PService;
|
||||
import bisq.network.p2p.P2PServiceListener;
|
||||
import bisq.network.p2p.peers.PeerManager;
|
||||
|
||||
import bisq.common.Timer;
|
||||
import bisq.common.UserThread;
|
||||
import bisq.common.app.AppModule;
|
||||
import bisq.common.app.Capabilities;
|
||||
@ -33,8 +35,10 @@ import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class SeedNodeMain extends ExecutableForAppWithP2p {
|
||||
private static final long CHECK_CONNECTION_LOSS_SEC = 30;
|
||||
private static final String VERSION = "1.4.2";
|
||||
private SeedNode seedNode;
|
||||
private Timer checkConnectionLossTime;
|
||||
|
||||
public SeedNodeMain() {
|
||||
super("Bisq Seednode", "bisq-seednode", "bisq_seednode", VERSION);
|
||||
@ -126,6 +130,7 @@ public class SeedNodeMain extends ExecutableForAppWithP2p {
|
||||
@Override
|
||||
public void onHiddenServicePublished() {
|
||||
startShutDownInterval(SeedNodeMain.this);
|
||||
UserThread.runAfter(() -> setupConnectionLossCheck(), 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -140,6 +145,19 @@ public class SeedNodeMain extends ExecutableForAppWithP2p {
|
||||
});
|
||||
}
|
||||
|
||||
private void setupConnectionLossCheck() {
|
||||
if (checkConnectionLossTime != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
checkConnectionLossTime = UserThread.runPeriodically(() -> {
|
||||
if (injector.getInstance(PeerManager.class).getNumAllConnectionsLostEvents() > 1) {
|
||||
shutDown(this);
|
||||
}
|
||||
}, CHECK_CONNECTION_LOSS_SEC);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gracefulShutDown(ResultHandler resultHandler) {
|
||||
seedNode.shutDown();
|
||||
|
Loading…
Reference in New Issue
Block a user