mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
Decrease failedConnectionAttempts onConnection
Rename method
This commit is contained in:
parent
351db88992
commit
2fd010498d
@ -208,6 +208,11 @@ public final class PeerManager implements ConnectionListener, PersistedDataHost
|
||||
stopped = false;
|
||||
listeners.forEach(Listener::onNewConnectionAfterAllConnectionsLost);
|
||||
}
|
||||
|
||||
if (connection.getPeersNodeAddressOptional().isPresent()) {
|
||||
findPeer(connection.getPeersNodeAddressOptional().get())
|
||||
.ifPresent(Peer::onConnection);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -253,16 +258,16 @@ public final class PeerManager implements ConnectionListener, PersistedDataHost
|
||||
}
|
||||
|
||||
public void handleConnectionFault(NodeAddress nodeAddress, @Nullable Connection connection) {
|
||||
log.debug("handleConnectionFault called: nodeAddress=" + nodeAddress);
|
||||
boolean doRemovePersistedPeer = false;
|
||||
removeReportedPeer(nodeAddress);
|
||||
Optional<Peer> persistedPeerOptional = findPersistedPeer(nodeAddress);
|
||||
if (persistedPeerOptional.isPresent()) {
|
||||
Peer persistedPeer = persistedPeerOptional.get();
|
||||
persistedPeer.increaseFailedConnectionAttempts();
|
||||
persistedPeer.onDisconnect();
|
||||
doRemovePersistedPeer = persistedPeer.tooManyFailedConnectionAttempts();
|
||||
}
|
||||
doRemovePersistedPeer = doRemovePersistedPeer || (connection != null && connection.getRuleViolation() != null);
|
||||
boolean ruleViolation = connection != null && connection.getRuleViolation() != null;
|
||||
doRemovePersistedPeer = doRemovePersistedPeer || ruleViolation;
|
||||
|
||||
if (doRemovePersistedPeer)
|
||||
removePersistedPeer(nodeAddress);
|
||||
|
@ -80,10 +80,14 @@ public final class Peer implements HasCapabilities, NetworkPayload, PersistableP
|
||||
// API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void increaseFailedConnectionAttempts() {
|
||||
public void onDisconnect() {
|
||||
this.failedConnectionAttempts++;
|
||||
}
|
||||
|
||||
public void onConnection() {
|
||||
this.failedConnectionAttempts--;
|
||||
}
|
||||
|
||||
public boolean tooManyFailedConnectionAttempts() {
|
||||
return failedConnectionAttempts >= MAX_FAILED_CONNECTION_ATTEMPTS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user