diff --git a/core/src/main/java/bisq/core/network/p2p/inventory/GetInventoryRequestHandler.java b/core/src/main/java/bisq/core/network/p2p/inventory/GetInventoryRequestHandler.java index 0098c513dcc..cbfe1a5edf8 100644 --- a/core/src/main/java/bisq/core/network/p2p/inventory/GetInventoryRequestHandler.java +++ b/core/src/main/java/bisq/core/network/p2p/inventory/GetInventoryRequestHandler.java @@ -157,6 +157,7 @@ public void onMessage(NetworkEnvelope networkEnvelope, Connection connection) { inventory.put(InventoryItem.maxConnections, String.valueOf(maxConnections)); inventory.put(InventoryItem.numConnections, String.valueOf(networkNode.getAllConnections().size())); inventory.put(InventoryItem.peakNumConnections, String.valueOf(peerManager.getPeakNumConnections())); + inventory.put(InventoryItem.numAllConnectionsLostEvents, String.valueOf(peerManager.getNumAllConnectionsLostEvents())); inventory.put(InventoryItem.sentBytes, String.valueOf(Statistic.totalSentBytesProperty().get())); inventory.put(InventoryItem.sentBytesPerSec, String.valueOf(Statistic.totalSentBytesPerSecProperty().get())); inventory.put(InventoryItem.receivedBytes, String.valueOf(Statistic.totalReceivedBytesProperty().get())); diff --git a/core/src/main/java/bisq/core/network/p2p/inventory/InventoryItem.java b/core/src/main/java/bisq/core/network/p2p/inventory/InventoryItem.java index ab730f98ab2..29fff373bd4 100644 --- a/core/src/main/java/bisq/core/network/p2p/inventory/InventoryItem.java +++ b/core/src/main/java/bisq/core/network/p2p/inventory/InventoryItem.java @@ -43,6 +43,7 @@ public enum InventoryItem { maxConnections("maxConnections", Integer.class, 0.33, 3, 0.4, 2.5), numConnections("numConnections", Integer.class, 0.33, 3, 0.4, 2.5), peakNumConnections("peakNumConnections", Integer.class, 0.33, 3, 0.4, 2.5), + numAllConnectionsLostEvents("numAllConnectionsLostEvents", Integer.class, 0.9, 1.1, 0.95, 1.05), sentBytes("sentBytes", Long.class, 0, 5, 0, 4), sentBytesPerSec("sentBytesPerSec", Double.class, 0, 3, 0, 2), receivedBytes("receivedBytes", Long.class, 0, 5, 0, 4), diff --git a/inventory/src/main/java/bisq/inventory/InventoryWebServer.java b/inventory/src/main/java/bisq/inventory/InventoryWebServer.java index dec26987faf..bbc8e2d8f54 100644 --- a/inventory/src/main/java/bisq/inventory/InventoryWebServer.java +++ b/inventory/src/main/java/bisq/inventory/InventoryWebServer.java @@ -288,7 +288,7 @@ private String getNetworkInfo(RequestInfo requestInfo, addInventoryItem("Max. connections: ", requestInfo, averageValues, sb, InventoryItem.maxConnections); addInventoryItem("Number of connections: ", requestInfo, averageValues, sb, InventoryItem.numConnections); addInventoryItem("Peak number of connections: ", requestInfo, averageValues, sb, InventoryItem.peakNumConnections); - + addInventoryItem("Number of 'All connections lost' events: ", requestInfo, averageValues, sb, InventoryItem.numAllConnectionsLostEvents); addInventoryItem("Sent messages/sec: ", requestInfo, averageValues, sb, InventoryItem.sentMessagesPerSec, value -> String.valueOf(MathUtils.roundDouble(Double.parseDouble(value), 2))); addInventoryItem("Received messages/sec: ", requestInfo, averageValues, sb, InventoryItem.receivedMessagesPerSec, diff --git a/p2p/src/main/java/bisq/network/p2p/peers/PeerManager.java b/p2p/src/main/java/bisq/network/p2p/peers/PeerManager.java index 1a7fd4d97cb..29a343cb81b 100644 --- a/p2p/src/main/java/bisq/network/p2p/peers/PeerManager.java +++ b/p2p/src/main/java/bisq/network/p2p/peers/PeerManager.java @@ -130,6 +130,8 @@ public interface Listener { private int peakNumConnections; @Setter private boolean allowDisconnectSeedNodes; + @Getter + private int numAllConnectionsLostEvents; /////////////////////////////////////////////////////////////////////////////////////////// @@ -208,6 +210,9 @@ public void onConnection(Connection connection) { if (lostAllConnections) { lostAllConnections = false; stopped = false; + log.info("\n------------------------------------------------------------\n" + + "Established a new connection from/to {} after all connections lost.\n" + + "------------------------------------------------------------", connection.getPeersNodeAddressOptional()); listeners.forEach(Listener::onNewConnectionAfterAllConnectionsLost); } connection.getPeersNodeAddressOptional() @@ -220,13 +225,22 @@ public void onDisconnect(CloseConnectionReason closeConnectionReason, Connection log.info("onDisconnect called: nodeAddress={}, closeConnectionReason={}", connection.getPeersNodeAddressOptional(), closeConnectionReason); handleConnectionFault(connection); + + boolean previousLostAllConnections = lostAllConnections; lostAllConnections = networkNode.getAllConnections().isEmpty(); + + // If we enter to 'All connections lost' we count the event. + if (!previousLostAllConnections && lostAllConnections) { + numAllConnectionsLostEvents++; + } + if (lostAllConnections) { stopped = true; log.warn("\n------------------------------------------------------------\n" + "All connections lost\n" + "------------------------------------------------------------"); listeners.forEach(Listener::onAllConnectionsLost); + } maybeRemoveBannedPeer(closeConnectionReason, connection); }