From b51344130078b93cfd5352472fd3924acccffc4d Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kittywhiskers@users.noreply.github.com> Date: Fri, 10 Jul 2020 16:48:20 +0100 Subject: [PATCH] merge bitcoin#19486: Remove unused constants CADDR_TIME_VERSION and GETHEADERS_VERSION --- src/protocol.h | 8 +++++++- src/version.h | 4 ---- test/functional/test_framework/messages.py | 12 ++++++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/protocol.h b/src/protocol.h index 8b0c25db42..c2eb3a2247 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -408,7 +408,13 @@ public: READWRITE(nVersion); } if ((s.GetType() & SER_DISK) || - (nVersion >= CADDR_TIME_VERSION && !(s.GetType() & SER_GETHASH))) { + (nVersion != INIT_PROTO_VERSION && !(s.GetType() & SER_GETHASH))) { + // The only time we serialize a CAddress object without nTime is in + // the initial VERSION messages which contain two CAddress records. + // At that point, the serialization version is INIT_PROTO_VERSION. + // After the version handshake, serialization version is >= + // MIN_PEER_PROTO_VERSION and all ADDR messages are serialized with + // nTime. READWRITE(obj.nTime); } if (nVersion & ADDRV2_FORMAT) { diff --git a/src/version.h b/src/version.h index 456b44d784..c8aa41bf0e 100644 --- a/src/version.h +++ b/src/version.h @@ -22,10 +22,6 @@ static const int MIN_PEER_PROTO_VERSION = 70215; //! minimum proto version of masternode to accept in DKGs static const int MIN_MASTERNODE_PROTO_VERSION = 70221; -//! nTime field added to CAddress, starting with this version; -//! if possible, avoid requesting addresses nodes older than this -static const int CADDR_TIME_VERSION = 31402; - //! protocol version is included in MNAUTH starting with this version static const int MNAUTH_NODE_VER_VERSION = 70218; diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index b4c12ac655..a878f95a50 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -255,7 +255,7 @@ class CAddress: self.ip = "0.0.0.0" self.port = 0 - def deserialize(self, f, with_time=True): + def deserialize(self, f, *, with_time=True): """Deserialize from addrv1 format (pre-BIP155)""" if with_time: # VERSION messages serialize CAddress objects without time @@ -267,7 +267,7 @@ class CAddress: self.ip = socket.inet_ntoa(f.read(4)) self.port = struct.unpack(">H", f.read(2))[0] - def serialize(self, with_time=True): + def serialize(self, *, with_time=True): """Serialize in addrv1 format (pre-BIP155)""" assert self.net == self.NET_IPV4 r = b"" @@ -1371,10 +1371,10 @@ class msg_version: self.nServices = struct.unpack("