Skip to content

Commit 0ecae66

Browse files
fanquakePastaPastaPasta
authored andcommitted
Merge bitcoin#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#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
1 parent ec11695 commit 0ecae66

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
@@ -20,6 +20,7 @@
2020
#include <net_permissions.h>
2121
#include <netaddress.h>
2222
#include <netbase.h>
23+
#include <protocol.h>
2324
#include <random.h>
2425
#include <scheduler.h>
2526
#include <ui_interface.h>
@@ -757,14 +758,14 @@ int CNode::GetSendVersion() const
757758
int V1TransportDeserializer::readHeader(Span<const uint8_t> msg_bytes)
758759
{
759760
// copy data to temporary parsing buffer
760-
unsigned int nRemaining = 24 - nHdrPos;
761+
unsigned int nRemaining = CMessageHeader::HEADER_SIZE - nHdrPos;
761762
unsigned int nCopy = std::min<unsigned int>(nRemaining, msg_bytes.size());
762763

763764
memcpy(&hdrbuf[nHdrPos], msg_bytes.data(), nCopy);
764765
nHdrPos += nCopy;
765766

766767
// if header incomplete, exit
767-
if (nHdrPos < 24)
768+
if (nHdrPos < CMessageHeader::HEADER_SIZE)
768769
return nCopy;
769770

770771
// deserialize to CMessageHeader

0 commit comments

Comments
 (0)