Skip to content

Commit 0f2fa59

Browse files
committed
Merge #18931: net: use CMessageHeader::HEADER_SIZE, add missing include
83da576 net: use CMessageHeader::HEADER_SIZE, add missing include (Jon Atack) Pull request description: as suggested 16 months ago by Gleb Naumenko in bitcoin/bitcoin#15197 (comment). `static constexpr CMessageHeader::HEADER_SIZE` is already used in this file, `src/net.cpp`, in 2 instances. This commit replaces the remaining 2 integer values in the file with it and adds the explicit include header. Co-authored by: Gleb Naumenko <[email protected]> ACKs for top commit: naumenkogs: utACK 83da576 practicalswift: ACK 83da576 -- patch looks correct theStack: ACK 83da576 -- verified that its just magic number elimination refactoring and additionally checked that all tests pass 👍 Tree-SHA512: 5b915483bca4ea162c259865a1b615d73b88a1b1db3f82db05f770d10b8a42494d948f5b21badbcce2d9efa5915b8cbb6af83073867c23d2f152c0d35ac37b96
2 parents ad1b7b1 + 83da576 commit 0f2fa59

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/net.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <crypto/sha256.h>
1717
#include <netbase.h>
1818
#include <net_permissions.h>
19+
#include <protocol.h>
1920
#include <random.h>
2021
#include <scheduler.h>
2122
#include <ui_interface.h>
@@ -631,14 +632,14 @@ int CNode::GetSendVersion() const
631632
int V1TransportDeserializer::readHeader(const char *pch, unsigned int nBytes)
632633
{
633634
// copy data to temporary parsing buffer
634-
unsigned int nRemaining = 24 - nHdrPos;
635+
unsigned int nRemaining = CMessageHeader::HEADER_SIZE - nHdrPos;
635636
unsigned int nCopy = std::min(nRemaining, nBytes);
636637

637638
memcpy(&hdrbuf[nHdrPos], pch, nCopy);
638639
nHdrPos += nCopy;
639640

640641
// if header incomplete, exit
641-
if (nHdrPos < 24)
642+
if (nHdrPos < CMessageHeader::HEADER_SIZE)
642643
return nCopy;
643644

644645
// deserialize to CMessageHeader

0 commit comments

Comments
 (0)