From 97c88b1efafa6da62b065aa2b4e0952891fa12e1 Mon Sep 17 00:00:00 2001 From: David Vorick Date: Tue, 12 Jun 2018 03:02:35 -0400 Subject: [PATCH] use one const for min acceptable peer version --- modules/gateway/consts.go | 6 ------ modules/gateway/peers.go | 2 +- modules/gateway/peers_test.go | 6 ++++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/modules/gateway/consts.go b/modules/gateway/consts.go index a506c7da77..cea7eb723b 100644 --- a/modules/gateway/consts.go +++ b/modules/gateway/consts.go @@ -25,12 +25,6 @@ const ( // connect to itself, this number can be reduced. maxLocalOutboundPeers = 3 - // minAcceptableVersion is the version below which the gateway will refuse to - // connect to peers and reject connection attempts. - // - // Reject peers < v1.3.0 due to hardfork. - minAcceptableVersion = "1.3.0" - // saveFrequency defines how often the gateway saves its persistence. saveFrequency = time.Minute * 2 diff --git a/modules/gateway/peers.go b/modules/gateway/peers.go index c0d80cdd79..8fe1c7a9f6 100644 --- a/modules/gateway/peers.go +++ b/modules/gateway/peers.go @@ -291,7 +291,7 @@ func acceptableVersion(version string) error { if !build.IsVersion(version) { return invalidVersionError(version) } - if build.VersionCmp(version, minAcceptableVersion) < 0 { + if build.VersionCmp(version, minimumAcceptablePeerVersion) < 0 { return insufficientVersionError(version) } return nil diff --git a/modules/gateway/peers_test.go b/modules/gateway/peers_test.go index 3fcdbb10b0..990d3f7895 100644 --- a/modules/gateway/peers_test.go +++ b/modules/gateway/peers_test.go @@ -414,6 +414,7 @@ func TestUnitAcceptableVersion(t *testing.T) { "0.3.3", "0.3.9.9.9.9.9.9.9.9.9.9", "0.3.9999999999", + "1.3.0", } for _, v := range insufficientVersions { err := acceptableVersion(v) @@ -422,8 +423,9 @@ func TestUnitAcceptableVersion(t *testing.T) { } } validVersions := []string{ - minAcceptableVersion, + minimumAcceptablePeerVersion, "1.4.0", + "1.3.1", "1.6.0", "1.6.1", "1.9", @@ -746,7 +748,7 @@ func TestAcceptConnRejectsVersions(t *testing.T) { // Test that acceptConn succeeds when the remote peer's version is // minAcceptableVersion { - remoteVersion: minAcceptableVersion, + remoteVersion: minimumAcceptablePeerVersion, versionResponseWant: build.Version, msg: "acceptConn should accept a remote peer whose version is 0.4.0", },