diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2015-03-07 05:34:31 -0800 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2015-03-07 05:38:34 -0800 |
commit | 2f10aa0fa122b089d8affbe725008f054a00fe46 (patch) | |
tree | ff176c05bac7107d27fc3220472d33a03bc29fb4 /src/protocol.cpp | |
parent | 7c3fbc34aed578398b3f180a621c671ff3837cec (diff) | |
parent | eec37136fd0f6ab80772380d8f047d98743f31f5 (diff) | |
download | bitcoin-2f10aa0fa122b089d8affbe725008f054a00fe46.tar.xz |
Merge pull request #5151
eec3713 make CMessageHeader a dumb storage class (Cory Fields)
Diffstat (limited to 'src/protocol.cpp')
-rw-r--r-- | src/protocol.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/protocol.cpp b/src/protocol.cpp index 74ac706d60..568580a595 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -5,7 +5,6 @@ #include "protocol.h" -#include "chainparams.h" #include "util.h" #include "utilstrencodings.h" @@ -21,17 +20,17 @@ static const char* ppszTypeName[] = "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)); nMessageSize = -1; 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)); strncpy(pchCommand, pszCommand, COMMAND_SIZE); nMessageSize = nMessageSizeIn; @@ -43,10 +42,10 @@ std::string CMessageHeader::GetCommand() const return std::string(pchCommand, pchCommand + strnlen(pchCommand, COMMAND_SIZE)); } -bool CMessageHeader::IsValid() const +bool CMessageHeader::IsValid(const MessageStartChars& pchMessageStartIn) const { // Check start string - if (memcmp(pchMessageStart, Params().MessageStart(), MESSAGE_START_SIZE) != 0) + if (memcmp(pchMessageStart, pchMessageStartIn, MESSAGE_START_SIZE) != 0) return false; // Check the command string for errors |