@@ -1087,25 +1087,25 @@ void PeerManagerImpl::PushNodeVersion(CNode& pnode, int64_t nTime)
1087
1087
// Note that pnode->GetLocalServices() is a reflection of the local
1088
1088
// services we were offering when the CNode object was created for this
1089
1089
// peer.
1090
- ServiceFlags nLocalNodeServices = pnode.GetLocalServices ();
1090
+ uint64_t my_services{ pnode.GetLocalServices ()} ;
1091
1091
uint64_t nonce = pnode.GetLocalNonce ();
1092
1092
const int nNodeStartingHeight{m_best_height};
1093
1093
NodeId nodeid = pnode.GetId ();
1094
1094
CAddress addr = pnode.addr ;
1095
1095
1096
- CAddress addrYou = addr.IsRoutable () && !IsProxy (addr) && addr.IsAddrV1Compatible () ?
1097
- addr :
1098
- CAddress (CService (), addr.nServices );
1099
- CAddress addrMe = CAddress (CService (), nLocalNodeServices);
1096
+ CService addr_you = addr.IsRoutable () && !IsProxy (addr) && addr.IsAddrV1Compatible () ? addr : CService ();
1097
+ uint64_t your_services{addr.nServices };
1100
1098
1101
1099
const bool tx_relay = !m_ignore_incoming_txs && pnode.m_tx_relay != nullptr ;
1102
- m_connman.PushMessage (&pnode, CNetMsgMaker (INIT_PROTO_VERSION).Make (NetMsgType::VERSION, PROTOCOL_VERSION, (uint64_t )nLocalNodeServices, nTime, addrYou, addrMe,
1100
+ m_connman.PushMessage (&pnode, CNetMsgMaker (INIT_PROTO_VERSION).Make (NetMsgType::VERSION, PROTOCOL_VERSION, my_services, nTime,
1101
+ your_services, addr_you, // Together the pre-version-31402 serialization of CAddress "addrYou" (without nTime)
1102
+ my_services, CService (), // Together the pre-version-31402 serialization of CAddress "addrMe" (without nTime)
1103
1103
nonce, strSubVersion, nNodeStartingHeight, tx_relay));
1104
1104
1105
1105
if (fLogIPs ) {
1106
- LogPrint (BCLog::NET, " send version message: version %d, blocks=%d, us=%s, them=%s, txrelay=%d, peer=%d\n " , PROTOCOL_VERSION, nNodeStartingHeight, addrMe .ToString (), addrYou .ToString (), tx_relay, nodeid);
1106
+ LogPrint (BCLog::NET, " send version message: version %d, blocks=%d, us=%s, them=%s, txrelay=%d, peer=%d\n " , PROTOCOL_VERSION, nNodeStartingHeight, CService () .ToString (), addr_you .ToString (), tx_relay, nodeid);
1107
1107
} else {
1108
- LogPrint (BCLog::NET, " send version message: version %d, blocks=%d, us=%s, txrelay=%d, peer=%d\n " , PROTOCOL_VERSION, nNodeStartingHeight, addrMe .ToString (), tx_relay, nodeid);
1108
+ LogPrint (BCLog::NET, " send version message: version %d, blocks=%d, us=%s, txrelay=%d, peer=%d\n " , PROTOCOL_VERSION, nNodeStartingHeight, CService () .ToString (), tx_relay, nodeid);
1109
1109
}
1110
1110
}
1111
1111
@@ -2487,21 +2487,20 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
2487
2487
}
2488
2488
2489
2489
int64_t nTime;
2490
- CAddress addrMe;
2491
- CAddress addrFrom;
2490
+ CService addrMe;
2492
2491
uint64_t nNonce = 1 ;
2493
- uint64_t nServiceInt;
2494
2492
ServiceFlags nServices;
2495
2493
int nVersion;
2496
2494
std::string cleanSubVer;
2497
2495
int starting_height = -1 ;
2498
2496
bool fRelay = true ;
2499
2497
2500
- vRecv >> nVersion >> nServiceInt >> nTime >> addrMe ;
2498
+ vRecv >> nVersion >> Using<CustomUintFormatter< 8 >>(nServices) >> nTime ;
2501
2499
if (nTime < 0 ) {
2502
2500
nTime = 0 ;
2503
2501
}
2504
- nServices = ServiceFlags (nServiceInt);
2502
+ vRecv.ignore (8 ); // Ignore the addrMe service bits sent by the peer
2503
+ vRecv >> addrMe;
2505
2504
if (!pfrom.IsInboundConn ())
2506
2505
{
2507
2506
m_addrman.SetServices (pfrom.addr , nServices);
@@ -2520,8 +2519,14 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
2520
2519
return ;
2521
2520
}
2522
2521
2523
- if (!vRecv.empty ())
2524
- vRecv >> addrFrom >> nNonce;
2522
+ if (!vRecv.empty ()) {
2523
+ // The version message includes information about the sending node which we don't use:
2524
+ // - 8 bytes (service bits)
2525
+ // - 16 bytes (ipv6 address)
2526
+ // - 2 bytes (port)
2527
+ vRecv.ignore (26 );
2528
+ vRecv >> nNonce;
2529
+ }
2525
2530
if (!vRecv.empty ()) {
2526
2531
std::string strSubVer;
2527
2532
vRecv >> LIMITED_STRING (strSubVer, MAX_SUBVERSION_LENGTH);
0 commit comments