mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user