| 412 | } |
| 413 | |
| 414 | bool 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)); |