@@ -2350,13 +2350,11 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
2350
2350
uint64_t nServiceInt;
2351
2351
ServiceFlags nServices;
2352
2352
int nVersion;
2353
- int nSendVersion;
2354
2353
std::string cleanSubVer;
2355
2354
int nStartingHeight = -1 ;
2356
2355
bool fRelay = true ;
2357
2356
2358
2357
vRecv >> nVersion >> nServiceInt >> nTime >> addrMe;
2359
- nSendVersion = std::min (nVersion, PROTOCOL_VERSION);
2360
2358
nServices = ServiceFlags (nServiceInt);
2361
2359
if (!pfrom.IsInboundConn ())
2362
2360
{
@@ -2405,11 +2403,16 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
2405
2403
if (pfrom.IsInboundConn ())
2406
2404
PushNodeVersion (pfrom, m_connman, GetAdjustedTime ());
2407
2405
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
+
2408
2411
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));
2410
2413
}
2411
2414
2412
- m_connman.PushMessage (&pfrom, CNetMsgMaker (nSendVersion ).Make (NetMsgType::VERACK));
2415
+ m_connman.PushMessage (&pfrom, CNetMsgMaker (greatest_common_version ).Make (NetMsgType::VERACK));
2413
2416
2414
2417
pfrom.nServices = nServices;
2415
2418
pfrom.SetAddrLocal (addrMe);
@@ -2430,10 +2433,6 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
2430
2433
pfrom.m_tx_relay ->fRelayTxes = fRelay ; // set to true after we get the first filter* message
2431
2434
}
2432
2435
2433
- // Change version
2434
- pfrom.SetCommonVersion (nSendVersion);
2435
- pfrom.nVersion = nVersion;
2436
-
2437
2436
if ((nServices & NODE_WITNESS))
2438
2437
{
2439
2438
LOCK (cs_main);
@@ -2479,7 +2478,7 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
2479
2478
}
2480
2479
2481
2480
// 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));
2483
2482
pfrom.fGetAddr = true ;
2484
2483
2485
2484
// 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
2503
2502
// If the peer is old enough to have the old alert system, send it the final alert.
2504
2503
if (pfrom.nVersion <= 70012 ) {
2505
2504
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));
2507
2506
}
2508
2507
2509
2508
// Feeler connections exist only to verify if address is online.
0 commit comments