Skip to content

Commit 38d49ea

Browse files
committed
Document 'DisconnectOldProtocol' call rationale in block processing.
Plus minor cleanup, removing unused parameter.
1 parent 4f62c04 commit 38d49ea

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/net.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,13 @@ void CNode::CloseSocketDisconnect()
417417
}
418418
}
419419

420-
bool CNode::DisconnectOldProtocol(int nVersionIn, int nVersionRequired, std::string strLastCommand)
420+
bool CNode::DisconnectOldProtocol(int nVersionIn, int nVersionRequired)
421421
{
422422
fDisconnect = false;
423423
if (nVersionIn < nVersionRequired) {
424424
LogPrintf("%s : peer=%d using obsolete version %i; disconnecting\n", __func__, id, nVersionIn);
425425
fDisconnect = true;
426426
}
427-
428427
return fDisconnect;
429428
}
430429

src/net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ class CNode
777777
}
778778

779779
void CloseSocketDisconnect();
780-
bool DisconnectOldProtocol(int nVersionIn, int nVersionRequired, std::string strLastCommand = "");
780+
bool DisconnectOldProtocol(int nVersionIn, int nVersionRequired);
781781

782782
void copyStats(CNodeStats& stats);
783783

src/net_processing.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,8 +1112,9 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR
11121112
return false;
11131113
}
11141114

1115-
if (pfrom->DisconnectOldProtocol(nVersion, ActiveProtocol(), strCommand))
1115+
if (pfrom->DisconnectOldProtocol(nVersion, ActiveProtocol())) {
11161116
return false;
1117+
}
11171118

11181119
if (nVersion == 10300)
11191120
nVersion = 300;
@@ -1700,8 +1701,10 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR
17001701
mapBlockSource.emplace(hashBlock, pfrom->GetId());
17011702
}
17021703
ProcessNewBlock(pblock, nullptr);
1703-
//disconnect this node if its old protocol version
1704-
pfrom->DisconnectOldProtocol(pfrom->nVersion, ActiveProtocol(), strCommand);
1704+
1705+
// Disconnect node if its running an old protocol version,
1706+
// used during upgrades, when the node is already connected.
1707+
pfrom->DisconnectOldProtocol(pfrom->nVersion, ActiveProtocol());
17051708
} else {
17061709
LogPrint(BCLog::NET, "%s : Already processed block %s, skipping ProcessNewBlock()\n", __func__, pblock->GetHash().GetHex());
17071710
}

0 commit comments

Comments
 (0)