diff --git a/src/main/java/org/qortal/network/Handshake.java b/src/main/java/org/qortal/network/Handshake.java index ed6d02db..8bee63a2 100644 --- a/src/main/java/org/qortal/network/Handshake.java +++ b/src/main/java/org/qortal/network/Handshake.java @@ -71,6 +71,15 @@ public enum Handshake { peer.setPeersConnectionTimestamp(peersConnectionTimestamp); 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; } diff --git a/src/main/java/org/qortal/settings/Settings.java b/src/main/java/org/qortal/settings/Settings.java index f94db927..164223c9 100644 --- a/src/main/java/org/qortal/settings/Settings.java +++ b/src/main/java/org/qortal/settings/Settings.java @@ -124,8 +124,13 @@ public class Settings { private int networkPoWComputePoolSize = 2; /** Maximum number of retry attempts if a peer fails to respond with the requested data */ private int maxRetries = 2; + /** Minimum peer version number required in order to sync with them */ 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 private String blockchainConfig = null; // use default from resources @@ -416,6 +421,8 @@ public class Settings { public String getMinPeerVersion() { return this.minPeerVersion; } + public boolean getAllowConnectionsWithOlderPeerVersions() { return this.allowConnectionsWithOlderPeerVersions; } + public String getBlockchainConfig() { return this.blockchainConfig; }