forked from Qortal/qortal
Don't intentionally disconnect peers if we are currently syncing with them.
This commit is contained in:
parent
73cc3dcb92
commit
78237fcd11
@ -722,6 +722,7 @@ public class Controller extends Thread {
|
|||||||
hasStatusChanged = true;
|
hasStatusChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
peer.setSyncInProgress(true);
|
||||||
|
|
||||||
if (hasStatusChanged)
|
if (hasStatusChanged)
|
||||||
updateSysTray();
|
updateSysTray();
|
||||||
@ -801,6 +802,7 @@ public class Controller extends Thread {
|
|||||||
return syncResult;
|
return syncResult;
|
||||||
} finally {
|
} finally {
|
||||||
isSynchronizing = false;
|
isSynchronizing = false;
|
||||||
|
peer.setSyncInProgress(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -645,10 +645,15 @@ public class Network {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find peers that have reached their maximum connection age, and disconnect them
|
// Find peers that have reached their maximum connection age, and disconnect them
|
||||||
List<Peer> peersToDisconnect = this.connectedPeers.stream().filter(peer -> peer.hasReachedMaxConnectionAge()).collect(Collectors.toList());
|
List<Peer> peersToDisconnect = this.connectedPeers.stream()
|
||||||
|
.filter(peer -> !peer.isSyncInProgress())
|
||||||
|
.filter(peer -> peer.hasReachedMaxConnectionAge())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
if (peersToDisconnect != null && peersToDisconnect.size() > 0) {
|
if (peersToDisconnect != null && peersToDisconnect.size() > 0) {
|
||||||
for (Peer peer : peersToDisconnect) {
|
for (Peer peer : peersToDisconnect) {
|
||||||
LOGGER.debug("Forcing disconnect of peer {} because connection age ({} ms) has reached the maximum ({} ms)", peer, peer.getConnectionAge(), peer.getMaxConnectionAge());
|
LOGGER.info("Forcing disconnection of peer {} because connection age ({} ms) " +
|
||||||
|
"has reached the maximum ({} ms)", peer, peer.getConnectionAge(), peer.getMaxConnectionAge());
|
||||||
peer.disconnect("Connection age too old");
|
peer.disconnect("Connection age too old");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,8 @@ public class Peer {
|
|||||||
|
|
||||||
byte[] ourChallenge;
|
byte[] ourChallenge;
|
||||||
|
|
||||||
|
private boolean syncInProgress = false;
|
||||||
|
|
||||||
// Versioning
|
// Versioning
|
||||||
public static final Pattern VERSION_PATTERN = Pattern.compile(Controller.VERSION_PREFIX
|
public static final Pattern VERSION_PATTERN = Pattern.compile(Controller.VERSION_PREFIX
|
||||||
+ "(\\d{1,3})\\.(\\d{1,5})\\.(\\d{1,5})");
|
+ "(\\d{1,3})\\.(\\d{1,5})\\.(\\d{1,5})");
|
||||||
@ -340,6 +342,14 @@ public class Peer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSyncInProgress() {
|
||||||
|
return this.syncInProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSyncInProgress(boolean syncInProgress) {
|
||||||
|
this.syncInProgress = syncInProgress;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
// Easier, and nicer output, than peer.getRemoteSocketAddress()
|
// Easier, and nicer output, than peer.getRemoteSocketAddress()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user