mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
Add peakNumConnections
This commit is contained in:
parent
5fb48fe72f
commit
8c156eb5bf
@ -31,6 +31,7 @@ import bisq.network.p2p.network.Connection;
|
||||
import bisq.network.p2p.network.MessageListener;
|
||||
import bisq.network.p2p.network.NetworkNode;
|
||||
import bisq.network.p2p.network.Statistic;
|
||||
import bisq.network.p2p.peers.PeerManager;
|
||||
import bisq.network.p2p.storage.P2PDataStorage;
|
||||
import bisq.network.p2p.storage.payload.ProtectedStorageEntry;
|
||||
|
||||
@ -60,6 +61,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Slf4j
|
||||
public class GetInventoryRequestHandler implements MessageListener {
|
||||
private final NetworkNode networkNode;
|
||||
private final PeerManager peerManager;
|
||||
private final P2PDataStorage p2PDataStorage;
|
||||
private final DaoStateService daoStateService;
|
||||
private final DaoStateMonitoringService daoStateMonitoringService;
|
||||
@ -70,6 +72,7 @@ public class GetInventoryRequestHandler implements MessageListener {
|
||||
|
||||
@Inject
|
||||
public GetInventoryRequestHandler(NetworkNode networkNode,
|
||||
PeerManager peerManager,
|
||||
P2PDataStorage p2PDataStorage,
|
||||
DaoStateService daoStateService,
|
||||
DaoStateMonitoringService daoStateMonitoringService,
|
||||
@ -77,6 +80,7 @@ public class GetInventoryRequestHandler implements MessageListener {
|
||||
BlindVoteStateMonitoringService blindVoteStateMonitoringService,
|
||||
@Named(Config.MAX_CONNECTIONS) int maxConnections) {
|
||||
this.networkNode = networkNode;
|
||||
this.peerManager = peerManager;
|
||||
this.p2PDataStorage = p2PDataStorage;
|
||||
this.daoStateService = daoStateService;
|
||||
this.daoStateMonitoringService = daoStateMonitoringService;
|
||||
@ -152,6 +156,7 @@ public class GetInventoryRequestHandler implements MessageListener {
|
||||
// network
|
||||
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.sentBytes, String.valueOf(Statistic.totalSentBytesProperty().get()));
|
||||
inventory.put(InventoryItem.sentBytesPerSec, String.valueOf(Statistic.totalSentBytesPerSecProperty().get()));
|
||||
inventory.put(InventoryItem.receivedBytes, String.valueOf(Statistic.totalReceivedBytesProperty().get()));
|
||||
|
@ -42,6 +42,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),
|
||||
sentBytes("sentBytes", Long.class, 0, 5, 0, 4),
|
||||
sentBytesPerSec("sentBytesPerSec", Double.class, 0, 3, 0, 2),
|
||||
receivedBytes("receivedBytes", Long.class, 0, 5, 0, 4),
|
||||
|
@ -287,6 +287,7 @@ public class InventoryWebServer {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
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("Sent messages/sec: ", requestInfo, averageValues, sb, InventoryItem.sentMessagesPerSec,
|
||||
value -> String.valueOf(MathUtils.roundDouble(Double.parseDouble(value), 2)));
|
||||
|
@ -126,6 +126,8 @@ public final class PeerManager implements ConnectionListener, PersistedDataHost
|
||||
private int maxConnectionsPeer;
|
||||
private int maxConnectionsNonDirect;
|
||||
private int maxConnectionsAbsolute;
|
||||
@Getter
|
||||
private int peakNumConnections;
|
||||
@Setter
|
||||
private boolean allowDisconnectSeedNodes;
|
||||
|
||||
@ -442,6 +444,10 @@ public final class PeerManager implements ConnectionListener, PersistedDataHost
|
||||
checkMaxConnectionsTimer = UserThread.runAfter(() -> {
|
||||
stopCheckMaxConnectionsTimer();
|
||||
if (!stopped) {
|
||||
Set<Connection> allConnections = new HashSet<>(networkNode.getAllConnections());
|
||||
int size = allConnections.size();
|
||||
peakNumConnections = Math.max(peakNumConnections, size);
|
||||
|
||||
removeAnonymousPeers();
|
||||
removeSuperfluousSeedNodes();
|
||||
removeTooOldReportedPeers();
|
||||
@ -458,6 +464,7 @@ public final class PeerManager implements ConnectionListener, PersistedDataHost
|
||||
boolean checkMaxConnections() {
|
||||
Set<Connection> allConnections = new HashSet<>(networkNode.getAllConnections());
|
||||
int size = allConnections.size();
|
||||
peakNumConnections = Math.max(peakNumConnections, size);
|
||||
log.info("We have {} connections open. Our limit is {}", size, maxConnections);
|
||||
|
||||
if (size <= maxConnections) {
|
||||
|
Loading…
Reference in New Issue
Block a user