Changeset View
Changeset View
Standalone View
Standalone View
src/protocol.cpp
Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | bool CMessageHeader::IsValid(const Config &config) const { | ||||
// Check start string | // Check start string | ||||
if (!CheckHeaderMagicAndCommand(*this, | if (!CheckHeaderMagicAndCommand(*this, | ||||
config.GetChainParams().NetMagic())) { | config.GetChainParams().NetMagic())) { | ||||
return false; | return false; | ||||
} | } | ||||
// Message size | // Message size | ||||
if (IsOversized(config)) { | if (IsOversized(config)) { | ||||
LogPrintf("CMessageHeader::IsValid(): (%s, %u bytes) is oversized\n", | LogPrint(BCLog::BENCH, | ||||
"CMessageHeader::IsValid(): (%s, %u bytes) is oversized\n", | |||||
GetCommand(), nMessageSize); | GetCommand(), nMessageSize); | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
/** | /** | ||||
* This is a transition method in order to stay compatible with older code that | * This is a transition method in order to stay compatible with older code that | ||||
* do not use the config. It assumes message will not get too large. This cannot | * do not use the config. It assumes message will not get too large. This cannot | ||||
* be used for any piece of code that will download blocks as blocks may be | * be used for any piece of code that will download blocks as blocks may be | ||||
* bigger than the permitted size. Idealy, code that uses this function should | * bigger than the permitted size. Idealy, code that uses this function should | ||||
* be migrated toward using the config. | * be migrated toward using the config. | ||||
*/ | */ | ||||
bool CMessageHeader::IsValidWithoutConfig(const MessageMagic &magic) const { | bool CMessageHeader::IsValidWithoutConfig(const MessageMagic &magic) const { | ||||
// Check start string | // Check start string | ||||
if (!CheckHeaderMagicAndCommand(*this, magic)) { | if (!CheckHeaderMagicAndCommand(*this, magic)) { | ||||
return false; | return false; | ||||
} | } | ||||
// Message size | // Message size | ||||
if (nMessageSize > MAX_PROTOCOL_MESSAGE_LENGTH) { | if (nMessageSize > MAX_PROTOCOL_MESSAGE_LENGTH) { | ||||
LogPrintf( | LogPrint( | ||||
BCLog::BENCH, | |||||
"CMessageHeader::IsValidForSeeder(): (%s, %u bytes) is oversized\n", | "CMessageHeader::IsValidForSeeder(): (%s, %u bytes) is oversized\n", | ||||
GetCommand(), nMessageSize); | GetCommand(), nMessageSize); | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |