diff options
| author | Wladimir J. van der Laan <[email protected]> | 2016-09-27 14:05:24 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2016-09-28 12:44:13 +0200 |
| commit | 41e58faf043864a64a6db08a8df527fa5fd1ec5b (patch) | |
| tree | dbe0c6c2dee6615abee3d97d6b8af98c66effc47 /src/protocol.cpp | |
| parent | Merge #8655: Do not shadow variables (trivials) (diff) | |
| download | discoin-41e58faf043864a64a6db08a8df527fa5fd1ec5b.tar.xz discoin-41e58faf043864a64a6db08a8df527fa5fd1ec5b.zip | |
net: Consistent checksum handling
In principle, the checksums of P2P packets are simply 4-byte blobs which
are the first four bytes of SHA256(SHA256(payload)).
Currently they are handled as little-endian 32-bit integers half of the
time, as blobs the other half, sometimes copying the one to the other,
resulting in somewhat confused code.
This PR changes the handling to be consistent both at packet creation
and receiving, making it (I think) easier to understand.
Diffstat (limited to 'src/protocol.cpp')
| -rw-r--r-- | src/protocol.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/protocol.cpp b/src/protocol.cpp index 247c6c212..54ad62b1a 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -79,7 +79,7 @@ CMessageHeader::CMessageHeader(const MessageStartChars& pchMessageStartIn) memcpy(pchMessageStart, pchMessageStartIn, MESSAGE_START_SIZE); memset(pchCommand, 0, sizeof(pchCommand)); nMessageSize = -1; - nChecksum = 0; + memset(pchChecksum, 0, CHECKSUM_SIZE); } CMessageHeader::CMessageHeader(const MessageStartChars& pchMessageStartIn, const char* pszCommand, unsigned int nMessageSizeIn) @@ -88,7 +88,7 @@ CMessageHeader::CMessageHeader(const MessageStartChars& pchMessageStartIn, const memset(pchCommand, 0, sizeof(pchCommand)); strncpy(pchCommand, pszCommand, COMMAND_SIZE); nMessageSize = nMessageSizeIn; - nChecksum = 0; + memset(pchChecksum, 0, CHECKSUM_SIZE); } std::string CMessageHeader::GetCommand() const |