X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fprotocol.cpp;h=5a7dd4a7472e941adf804a23d47f9aa275d52d1a;hb=3814af1ef1a10f25e7a76929edfd3abdb0ab791d;hp=4b8b4363cd51d4a59a5d13b56b3ee251e56fe6fd;hpb=83e34b29071b58d6578b197430d12c55d277a515;p=novacoin.git diff --git a/src/protocol.cpp b/src/protocol.cpp index 4b8b436..5a7dd4a 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -11,21 +11,6 @@ # include #endif -// The message start string is designed to be unlikely to occur in normal data. -// The characters are rarely used upper ascii, not valid as UTF-8, and produce -// a large 4-byte int at any alignment. - -static unsigned char pchMessageStartTestNew[4] = { 0xcd, 0xf2, 0xc0, 0xef }; -static unsigned char pchMessageStartPPCoin[4] = { 0xe4, 0xe8, 0xe9, 0xe5 }; - -void GetMessageStart(unsigned char pchMessageStart[], bool fPersistent) -{ - if (fTestNet) - memcpy(pchMessageStart, pchMessageStartTestNew, sizeof(pchMessageStartTestNew)); - else - memcpy(pchMessageStart, pchMessageStartPPCoin, sizeof(pchMessageStartPPCoin)); -} - static const char* ppszTypeName[] = { "ERROR", @@ -35,16 +20,16 @@ static const char* ppszTypeName[] = CMessageHeader::CMessageHeader() { - GetMessageStart(pchMessageStart); + memcpy(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart)); memset(pchCommand, 0, sizeof(pchCommand)); pchCommand[1] = 1; - nMessageSize = -1; + nMessageSize = std::numeric_limits::max(); nChecksum = 0; } CMessageHeader::CMessageHeader(const char* pszCommand, unsigned int nMessageSizeIn) { - GetMessageStart(pchMessageStart); + memcpy(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart)); strncpy(pchCommand, pszCommand, COMMAND_SIZE); nMessageSize = nMessageSizeIn; nChecksum = 0; @@ -61,9 +46,7 @@ std::string CMessageHeader::GetCommand() const bool CMessageHeader::IsValid() const { // Check start string - unsigned char pchMessageStartProtocol[4]; - GetMessageStart(pchMessageStartProtocol); - if (memcmp(pchMessageStart, pchMessageStartProtocol, sizeof(pchMessageStart)) != 0) + if (memcmp(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart)) != 0) return false; // Check the command string for errors @@ -97,7 +80,7 @@ CAddress::CAddress() : CService() Init(); } -CAddress::CAddress(CService ipIn, uint64 nServicesIn) : CService(ipIn) +CAddress::CAddress(CService ipIn, uint64_t nServicesIn) : CService(ipIn) { Init(); nServices = nServicesIn;