@@ -1199,16 +1199,23 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR
1199
1199
CAddress addrFrom;
1200
1200
uint64_t nNonce = 1 ;
1201
1201
uint64_t nServiceInt;
1202
+ ServiceFlags nServices;
1202
1203
int nVersion;
1204
+ int nSendVersion;
1205
+ std::string strSubVer;
1206
+ int nStartingHeight = -1 ;
1207
+ bool fRelay = true ;
1208
+
1203
1209
vRecv >> nVersion >> nServiceInt >> nTime >> addrMe;
1204
- pfrom->nServices = ServiceFlags (nServiceInt);
1210
+ nSendVersion = std::min (nVersion, PROTOCOL_VERSION);
1211
+ nServices = ServiceFlags (nServiceInt);
1205
1212
if (!pfrom->fInbound )
1206
1213
{
1207
- connman.SetServices (pfrom->addr , pfrom-> nServices );
1214
+ connman.SetServices (pfrom->addr , nServices);
1208
1215
}
1209
- if (pfrom->nServicesExpected & ~pfrom-> nServices )
1216
+ if (pfrom->nServicesExpected & ~nServices)
1210
1217
{
1211
- LogPrint (" net" , " peer=%d does not offer the expected services (%08x offered, %08x expected); disconnecting\n " , pfrom->id , pfrom-> nServices , pfrom->nServicesExpected );
1218
+ LogPrint (" net" , " peer=%d does not offer the expected services (%08x offered, %08x expected); disconnecting\n " , pfrom->id , nServices, pfrom->nServicesExpected );
1212
1219
connman.PushMessage (pfrom, CNetMsgMaker (INIT_PROTO_VERSION).Make (NetMsgType::REJECT, strCommand, REJECT_NONSTANDARD,
1213
1220
strprintf (" Expected to offer services %08x" , pfrom->nServicesExpected )));
1214
1221
pfrom->fDisconnect = true ;
@@ -1230,20 +1237,13 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR
1230
1237
if (!vRecv.empty ())
1231
1238
vRecv >> addrFrom >> nNonce;
1232
1239
if (!vRecv.empty ()) {
1233
- vRecv >> LIMITED_STRING (pfrom->strSubVer , MAX_SUBVERSION_LENGTH);
1234
- pfrom->cleanSubVer = SanitizeString (pfrom->strSubVer );
1240
+ vRecv >> LIMITED_STRING (strSubVer, MAX_SUBVERSION_LENGTH);
1235
1241
}
1236
1242
if (!vRecv.empty ()) {
1237
- vRecv >> pfrom-> nStartingHeight ;
1243
+ vRecv >> nStartingHeight;
1238
1244
}
1239
- {
1240
- LOCK (pfrom->cs_filter );
1241
- if (!vRecv.empty ())
1242
- vRecv >> pfrom->fRelayTxes ; // set to true after we get the first filter* message
1243
- else
1244
- pfrom->fRelayTxes = true ;
1245
- }
1246
-
1245
+ if (!vRecv.empty ())
1246
+ vRecv >> fRelay ;
1247
1247
// Disconnect if we connected to ourself
1248
1248
if (pfrom->fInbound && !connman.CheckIncomingNonce (nNonce))
1249
1249
{
@@ -1252,7 +1252,6 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR
1252
1252
return true ;
1253
1253
}
1254
1254
1255
- pfrom->addrLocal = addrMe;
1256
1255
if (pfrom->fInbound && addrMe.IsRoutable ())
1257
1256
{
1258
1257
SeenLocal (addrMe);
@@ -1262,9 +1261,25 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR
1262
1261
if (pfrom->fInbound )
1263
1262
PushNodeVersion (pfrom, connman, GetAdjustedTime ());
1264
1263
1265
- pfrom->fClient = !(pfrom->nServices & NODE_NETWORK);
1264
+ connman.PushMessage (pfrom, CNetMsgMaker (INIT_PROTO_VERSION).Make (NetMsgType::VERACK));
1265
+
1266
+ pfrom->nServices = nServices;
1267
+ pfrom->addrLocal = addrMe;
1268
+ pfrom->strSubVer = strSubVer;
1269
+ pfrom->cleanSubVer = SanitizeString (strSubVer);
1270
+ pfrom->nStartingHeight = nStartingHeight;
1271
+ pfrom->fClient = !(nServices & NODE_NETWORK);
1272
+ {
1273
+ LOCK (pfrom->cs_filter );
1274
+ pfrom->fRelayTxes = fRelay ; // set to true after we get the first filter* message
1275
+ }
1276
+
1277
+ // Change version
1278
+ pfrom->SetSendVersion (nSendVersion);
1279
+ pfrom->nVersion = nVersion;
1280
+ pfrom->fSuccessfullyConnected = true ;
1266
1281
1267
- if ((pfrom-> nServices & NODE_WITNESS))
1282
+ if ((nServices & NODE_WITNESS))
1268
1283
{
1269
1284
LOCK (cs_main);
1270
1285
State (pfrom->GetId ())->fHaveWitness = true ;
@@ -1276,12 +1291,6 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR
1276
1291
UpdatePreferredDownload (pfrom, State (pfrom->GetId ()));
1277
1292
}
1278
1293
1279
- // Change version
1280
- connman.PushMessage (pfrom, CNetMsgMaker (INIT_PROTO_VERSION).Make (NetMsgType::VERACK));
1281
- int nSendVersion = std::min (nVersion, PROTOCOL_VERSION);
1282
- pfrom->nVersion = nVersion;
1283
- pfrom->SetSendVersion (nSendVersion);
1284
-
1285
1294
if (!pfrom->fInbound )
1286
1295
{
1287
1296
// Advertise our address
@@ -1309,8 +1318,6 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR
1309
1318
connman.MarkAddressGood (pfrom->addr );
1310
1319
}
1311
1320
1312
- pfrom->fSuccessfullyConnected = true ;
1313
-
1314
1321
std::string remoteAddr;
1315
1322
if (fLogIPs )
1316
1323
remoteAddr = " , peeraddr=" + pfrom->addr .ToString ();
@@ -1352,7 +1359,7 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR
1352
1359
1353
1360
if (strCommand == NetMsgType::VERACK)
1354
1361
{
1355
- pfrom->SetRecvVersion (std::min (pfrom->nVersion , PROTOCOL_VERSION));
1362
+ pfrom->SetRecvVersion (std::min (pfrom->nVersion . load () , PROTOCOL_VERSION));
1356
1363
1357
1364
if (!pfrom->fInbound ) {
1358
1365
// Mark this node as currently connected, so we update its timestamp later.
0 commit comments