Browse Source

Added "allowConnectionsWithOlderPeerVersions" setting (default: true)

This controls 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. This is the default, which allows older nodes to continue functioning, but prevents them from interfering with the sync behaviour of updated nodes.

If false, sync will be blocked both ways, and they will not appear in the peers list at all.
ignore-old-versions
CalDescent 3 years ago
parent
commit
26c1793d85
  1. 9
      src/main/java/org/qortal/network/Handshake.java
  2. 7
      src/main/java/org/qortal/settings/Settings.java

9
src/main/java/org/qortal/network/Handshake.java

@ -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;
} }

7
src/main/java/org/qortal/settings/Settings.java

@ -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…
Cancel
Save