|
|
@ -5,7 +5,6 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "protocol.h" |
|
|
|
#include "protocol.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "chainparams.h" |
|
|
|
|
|
|
|
#include "util.h" |
|
|
|
#include "util.h" |
|
|
|
#include "utilstrencodings.h" |
|
|
|
#include "utilstrencodings.h" |
|
|
|
|
|
|
|
|
|
|
@ -21,17 +20,17 @@ static const char* ppszTypeName[] = |
|
|
|
"filtered block" |
|
|
|
"filtered block" |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
CMessageHeader::CMessageHeader() |
|
|
|
CMessageHeader::CMessageHeader(const MessageStartChars& pchMessageStartIn) |
|
|
|
{ |
|
|
|
{ |
|
|
|
memcpy(pchMessageStart, Params().MessageStart(), MESSAGE_START_SIZE); |
|
|
|
memcpy(pchMessageStart, pchMessageStartIn, MESSAGE_START_SIZE); |
|
|
|
memset(pchCommand, 0, sizeof(pchCommand)); |
|
|
|
memset(pchCommand, 0, sizeof(pchCommand)); |
|
|
|
nMessageSize = -1; |
|
|
|
nMessageSize = -1; |
|
|
|
nChecksum = 0; |
|
|
|
nChecksum = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CMessageHeader::CMessageHeader(const char* pszCommand, unsigned int nMessageSizeIn) |
|
|
|
CMessageHeader::CMessageHeader(const MessageStartChars& pchMessageStartIn, const char* pszCommand, unsigned int nMessageSizeIn) |
|
|
|
{ |
|
|
|
{ |
|
|
|
memcpy(pchMessageStart, Params().MessageStart(), MESSAGE_START_SIZE); |
|
|
|
memcpy(pchMessageStart, pchMessageStartIn, MESSAGE_START_SIZE); |
|
|
|
memset(pchCommand, 0, sizeof(pchCommand)); |
|
|
|
memset(pchCommand, 0, sizeof(pchCommand)); |
|
|
|
strncpy(pchCommand, pszCommand, COMMAND_SIZE); |
|
|
|
strncpy(pchCommand, pszCommand, COMMAND_SIZE); |
|
|
|
nMessageSize = nMessageSizeIn; |
|
|
|
nMessageSize = nMessageSizeIn; |
|
|
@ -43,10 +42,10 @@ std::string CMessageHeader::GetCommand() const |
|
|
|
return std::string(pchCommand, pchCommand + strnlen(pchCommand, COMMAND_SIZE)); |
|
|
|
return std::string(pchCommand, pchCommand + strnlen(pchCommand, COMMAND_SIZE)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool CMessageHeader::IsValid() const |
|
|
|
bool CMessageHeader::IsValid(const MessageStartChars& pchMessageStartIn) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Check start string
|
|
|
|
// Check start string
|
|
|
|
if (memcmp(pchMessageStart, Params().MessageStart(), MESSAGE_START_SIZE) != 0) |
|
|
|
if (memcmp(pchMessageStart, pchMessageStartIn, MESSAGE_START_SIZE) != 0) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
// Check the command string for errors
|
|
|
|
// Check the command string for errors
|
|
|
|