Skip to content

Commit 8d20267

Browse files
committed
refactor: Rename local variable nSendVersion
1 parent e9a6d8b commit 8d20267

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/net_processing.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,13 +2350,11 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
23502350
uint64_t nServiceInt;
23512351
ServiceFlags nServices;
23522352
int nVersion;
2353-
int nSendVersion;
23542353
std::string cleanSubVer;
23552354
int nStartingHeight = -1;
23562355
bool fRelay = true;
23572356

23582357
vRecv >> nVersion >> nServiceInt >> nTime >> addrMe;
2359-
nSendVersion = std::min(nVersion, PROTOCOL_VERSION);
23602358
nServices = ServiceFlags(nServiceInt);
23612359
if (!pfrom.IsInboundConn())
23622360
{
@@ -2405,11 +2403,16 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
24052403
if (pfrom.IsInboundConn())
24062404
PushNodeVersion(pfrom, m_connman, GetAdjustedTime());
24072405

2406+
// Change version
2407+
const int greatest_common_version = std::min(nVersion, PROTOCOL_VERSION);
2408+
pfrom.SetCommonVersion(greatest_common_version);
2409+
pfrom.nVersion = nVersion;
2410+
24082411
if (nVersion >= WTXID_RELAY_VERSION) {
2409-
m_connman.PushMessage(&pfrom, CNetMsgMaker(nSendVersion).Make(NetMsgType::WTXIDRELAY));
2412+
m_connman.PushMessage(&pfrom, CNetMsgMaker(greatest_common_version).Make(NetMsgType::WTXIDRELAY));
24102413
}
24112414

2412-
m_connman.PushMessage(&pfrom, CNetMsgMaker(nSendVersion).Make(NetMsgType::VERACK));
2415+
m_connman.PushMessage(&pfrom, CNetMsgMaker(greatest_common_version).Make(NetMsgType::VERACK));
24132416

24142417
pfrom.nServices = nServices;
24152418
pfrom.SetAddrLocal(addrMe);
@@ -2430,10 +2433,6 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
24302433
pfrom.m_tx_relay->fRelayTxes = fRelay; // set to true after we get the first filter* message
24312434
}
24322435

2433-
// Change version
2434-
pfrom.SetCommonVersion(nSendVersion);
2435-
pfrom.nVersion = nVersion;
2436-
24372436
if((nServices & NODE_WITNESS))
24382437
{
24392438
LOCK(cs_main);
@@ -2479,7 +2478,7 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
24792478
}
24802479

24812480
// Get recent addresses
2482-
m_connman.PushMessage(&pfrom, CNetMsgMaker(nSendVersion).Make(NetMsgType::GETADDR));
2481+
m_connman.PushMessage(&pfrom, CNetMsgMaker(greatest_common_version).Make(NetMsgType::GETADDR));
24832482
pfrom.fGetAddr = true;
24842483

24852484
// Moves address from New to Tried table in Addrman, resolves
@@ -2503,7 +2502,7 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
25032502
// If the peer is old enough to have the old alert system, send it the final alert.
25042503
if (pfrom.nVersion <= 70012) {
25052504
CDataStream finalAlert(ParseHex("60010000000000000000000000ffffff7f00000000ffffff7ffeffff7f01ffffff7f00000000ffffff7f00ffffff7f002f555247454e543a20416c657274206b657920636f6d70726f6d697365642c2075706772616465207265717569726564004630440220653febd6410f470f6bae11cad19c48413becb1ac2c17f908fd0fd53bdc3abd5202206d0e9c96fe88d4a0f01ed9dedae2b6f9e00da94cad0fecaae66ecf689bf71b50"), SER_NETWORK, PROTOCOL_VERSION);
2506-
m_connman.PushMessage(&pfrom, CNetMsgMaker(nSendVersion).Make("alert", finalAlert));
2505+
m_connman.PushMessage(&pfrom, CNetMsgMaker(greatest_common_version).Make("alert", finalAlert));
25072506
}
25082507

25092508
// Feeler connections exist only to verify if address is online.

0 commit comments

Comments
 (0)