MCPcopy Create free account
hub / github.com/BitcoinUnlimited/BitcoinUnlimited / ProcessMessage

Function ProcessMessage

src/net_processing.cpp:414–2174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412}
413
414bool ProcessMessage(CNode *pfrom, std::string strCommand, CDataStream &vRecv, int64_t nStopwatchTimeReceived)
415{
416 int64_t receiptTime = GetTime();
417 const CChainParams &chainparams = Params();
418 unsigned int msgSize = vRecv.size(); // BU for statistics
419 UpdateRecvStats(pfrom, strCommand, msgSize, nStopwatchTimeReceived);
420 LOG(NET, "received: %s (%u bytes) peer=%s\n", SanitizeString(strCommand), msgSize, pfrom->GetLogName());
421 if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
422 {
423 LOGA("dropmessagestest DROPPING RECV MESSAGE\n");
424 return true;
425 }
426
427 if (!(nLocalServices & NODE_BLOOM) &&
428 (strCommand == NetMsgType::FILTERLOAD || strCommand == NetMsgType::FILTERADD ||
429 strCommand == NetMsgType::FILTERCLEAR))
430 {
431 if (pfrom->nVersion >= NO_BLOOM_VERSION)
432 {
433 dosMan.Misbehaving(pfrom, 100);
434 return false;
435 }
436 else
437 {
438 LOG(NET, "Inconsistent bloom filter settings peer %s\n", pfrom->GetLogName());
439 pfrom->fDisconnect = true;
440 return false;
441 }
442 }
443
444 bool grapheneVersionCompatible = true;
445 try
446 {
447 NegotiateGrapheneVersion(pfrom);
448 NegotiateFastFilterSupport(pfrom);
449 }
450 catch (const std::runtime_error &e)
451 {
452 grapheneVersionCompatible = false;
453 }
454
455 // ------------------------- BEGIN INITIAL COMMAND SET PROCESSING
456 if (strCommand == NetMsgType::VERSION)
457 {
458 int64_t nTime;
459 CAddress addrMe;
460 uint64_t nNonce = 1;
461 vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe;
462
463 // Update thin type peer counters. This should be at the top here before we have any
464 // potential disconnects, because on disconnect the counters will then get decremented.
465 thinrelay.AddPeers(pfrom);
466
467 if (pfrom->nVersion < MIN_PEER_PROTO_VERSION)
468 {
469 // ban peers older than this proto version
470 pfrom->PushMessage(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
471 strprintf("Protocol Version must be %d or greater", MIN_PEER_PROTO_VERSION));

Callers 2

ProcessMessagesFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 15

GetTimeFunction · 0.85
UpdateRecvStatsFunction · 0.85
SanitizeStringFunction · 0.85
GetRandFunction · 0.85
atoiFunction · 0.85
NegotiateGrapheneVersionFunction · 0.85
errorFunction · 0.85
GetRandIntFunction · 0.85
SeenLocalFunction · 0.85
UpdatePreferredDownloadFunction · 0.85
GetListenPortFunction · 0.85

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68