MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / SanityCheckMessage

Function SanityCheckMessage

src/main.cpp:4506–4521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4504 ;
4505
4506bool static SanityCheckMessage(CNode* peer, const CNetMessage& msg)
4507{
4508 const std::string& strCommand = msg.hdr.GetCommand();
4509 uint64_t nMaxMessageSize = NextBlockRaiseCap(GetMaxBlockSize());
4510 if (msg.hdr.nMessageSize > nMaxMessageSize ||
4511 (maxMessageSizes.count(strCommand) && msg.hdr.nMessageSize > maxMessageSizes[strCommand])) {
4512 LogPrint("net", "Oversized %s message from peer=%i (%d bytes)\n",
4513 SanitizeString(strCommand), peer->GetId(), msg.hdr.nMessageSize);
4514 Misbehaving(peer->GetId(), 20);
4515 return msg.hdr.nMessageSize <= nMaxMessageSize;
4516 }
4517 // This would be a good place for more sophisticated DoS detection/prevention.
4518 // (e.g. disconnect a peer that is flooding us with excessive messages)
4519
4520 return true;
4521}
4522
4523
4524bool static AlreadyHave(const CInv& inv)

Callers

nothing calls this directly

Calls 7

NextBlockRaiseCapFunction · 0.85
GetMaxBlockSizeFunction · 0.85
SanitizeStringFunction · 0.85
MisbehavingFunction · 0.85
GetCommandMethod · 0.80
countMethod · 0.80
GetIdMethod · 0.80

Tested by

no test coverage detected