forked from Qortal/qortal
Merge branch 'ignore-old-versions'
This commit is contained in:
commit
83e2b10904
@ -71,6 +71,15 @@ public enum Handshake {
|
|||||||
peer.setPeersConnectionTimestamp(peersConnectionTimestamp);
|
peer.setPeersConnectionTimestamp(peersConnectionTimestamp);
|
||||||
peer.setPeersVersion(versionString, version);
|
peer.setPeersVersion(versionString, version);
|
||||||
|
|
||||||
|
if (Settings.getInstance().getAllowConnectionsWithOlderPeerVersions() == false) {
|
||||||
|
// Ensure the peer is running at least the minimum version allowed for connections
|
||||||
|
final String minPeerVersion = Settings.getInstance().getMinPeerVersion();
|
||||||
|
if (peer.isAtLeastVersion(minPeerVersion) == false) {
|
||||||
|
LOGGER.info(String.format("Ignoring peer %s because it is on an old version (%s)", peer, versionString));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return CHALLENGE;
|
return CHALLENGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,8 +124,13 @@ public class Settings {
|
|||||||
private int networkPoWComputePoolSize = 2;
|
private int networkPoWComputePoolSize = 2;
|
||||||
/** Maximum number of retry attempts if a peer fails to respond with the requested data */
|
/** Maximum number of retry attempts if a peer fails to respond with the requested data */
|
||||||
private int maxRetries = 2;
|
private int maxRetries = 2;
|
||||||
|
|
||||||
/** Minimum peer version number required in order to sync with them */
|
/** Minimum peer version number required in order to sync with them */
|
||||||
private String minPeerVersion = "1.5.0";
|
private String minPeerVersion = "1.5.0";
|
||||||
|
/** Whether to allow connections with peers below minPeerVersion
|
||||||
|
* If true, we won't sync with them but they can still sync with us, and will show in the peers list
|
||||||
|
* If false, sync will be blocked both ways, and they will not appear in the peers list */
|
||||||
|
private boolean allowConnectionsWithOlderPeerVersions = true;
|
||||||
|
|
||||||
// Which blockchains this node is running
|
// Which blockchains this node is running
|
||||||
private String blockchainConfig = null; // use default from resources
|
private String blockchainConfig = null; // use default from resources
|
||||||
@ -416,6 +421,8 @@ public class Settings {
|
|||||||
|
|
||||||
public String getMinPeerVersion() { return this.minPeerVersion; }
|
public String getMinPeerVersion() { return this.minPeerVersion; }
|
||||||
|
|
||||||
|
public boolean getAllowConnectionsWithOlderPeerVersions() { return this.allowConnectionsWithOlderPeerVersions; }
|
||||||
|
|
||||||
public String getBlockchainConfig() {
|
public String getBlockchainConfig() {
|
||||||
return this.blockchainConfig;
|
return this.blockchainConfig;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user