Skip to content

Commit

Permalink
Merge bitcoin#14025: p2p: Remove dead code for nVersion=10300
Browse files Browse the repository at this point in the history
fa74d3d qa: Remove unused deserialization code in msg_version (MarcoFalke)
fa5099c p2p: Remove dead code for nVersion=10300 (MarcoFalke)

Pull request description:

  This code is undocumented and confusing as well as dead, since peers with a version that old are disconnected immediately.

Tree-SHA512: 58c131a2730b630ffdc191cd65fe736ed1bd57e184902e2af1b1399443c4654617e68774432016df023434055e85d2e8cd32fb03b40c508c3bb8db6d19427434
  • Loading branch information
MarcoFalke authored and PastaPastaPasta committed May 12, 2020
1 parent aa44613 commit dcb27c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
5 changes: 1 addition & 4 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2123,8 +2123,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
return false;
}

if (nVersion < MIN_PEER_PROTO_VERSION)
{
if (nVersion < MIN_PEER_PROTO_VERSION) {
// disconnect from peers older than this proto version
LogPrint(BCLog::NET, "peer=%d using obsolete version %i; disconnecting\n", pfrom->GetId(), nVersion);
if (enable_bip61) {
Expand All @@ -2135,8 +2134,6 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
return false;
}

if (nVersion == 10300)
nVersion = 300;
if (!vRecv.empty())
vRecv >> addrFrom >> nNonce;
if (!vRecv.empty()) {
Expand Down
21 changes: 5 additions & 16 deletions test/functional/test_framework/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,28 +892,17 @@ def __init__(self):

def deserialize(self, f):
self.nVersion = struct.unpack("<i", f.read(4))[0]
if self.nVersion == 10300:
self.nVersion = 300
self.nServices = struct.unpack("<Q", f.read(8))[0]
self.nTime = struct.unpack("<q", f.read(8))[0]
self.addrTo = CAddress()
self.addrTo.deserialize(f, False)

if self.nVersion >= 106:
self.addrFrom = CAddress()
self.addrFrom.deserialize(f, False)
self.nNonce = struct.unpack("<Q", f.read(8))[0]
self.strSubVer = deser_string(f)
else:
self.addrFrom = None
self.nNonce = None
self.strSubVer = None
self.nStartingHeight = None
self.addrFrom = CAddress()
self.addrFrom.deserialize(f, False)
self.nNonce = struct.unpack("<Q", f.read(8))[0]
self.strSubVer = deser_string(f)

if self.nVersion >= 209:
self.nStartingHeight = struct.unpack("<i", f.read(4))[0]
else:
self.nStartingHeight = None
self.nStartingHeight = struct.unpack("<i", f.read(4))[0]

if self.nVersion >= 70001:
# Relay field is optional for version 70001 onwards
Expand Down

0 comments on commit dcb27c8

Please sign in to comment.