Skip to content

Commit

Permalink
add debug log for disconnecting an established peer
Browse files Browse the repository at this point in the history
  • Loading branch information
pinges committed Dec 14, 2023
1 parent b62c7a2 commit a337253
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,11 @@ private boolean registerDisconnect(
disconnectCallbacks.forEach(callback -> callback.onDisconnect(peer));
peer.handleDisconnect();
abortPendingRequestsAssignedToDisconnectedPeers();
LOG.debug("Disconnected EthPeer {}", peer.getShortNodeId());
if (System.currentTimeMillis() - peer.getConnection().getInitiatedAt() > 600000) {
LOG.debug("Disonnected ESTABLISHED peer {}", peer);
} else {
LOG.debug("Disconnected EthPeer {}", peer.getShortNodeId());
}
LOG.trace("Disconnected EthPeer {}", peer);
}
}
Expand All @@ -218,9 +222,8 @@ private void abortPendingRequestsAssignedToDisconnectedPeers() {
}

public EthPeer peer(final PeerConnection connection) {
final EthPeer ethPeer = incompleteConnections.getIfPresent(
connection);
return ethPeer != null ? ethPeer : completeConnections.get(connection.getPeer().getId());
final EthPeer ethPeer = incompleteConnections.getIfPresent(connection);
return ethPeer != null ? ethPeer : completeConnections.get(connection.getPeer().getId());
}

public EthPeer peer(final Bytes peerId) {
Expand Down Expand Up @@ -363,7 +366,7 @@ public Stream<PeerConnection> getAllConnections() {

public boolean shouldConnect(final Peer peer, final boolean inbound) {
final Bytes id = peer.getId();
if (peerCount() >= peerUpperBound && !canExceedPeerLimits(id) ) {
if (peerCount() >= peerUpperBound && !canExceedPeerLimits(id)) {
return false;
}
final EthPeer ethPeer = completeConnections.get(id);
Expand Down

0 comments on commit a337253

Please sign in to comment.