net: use CMessageHeader::HEADER_SIZE, add missing include

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 with it and adds the explicit include header.

Co-authored by: Gleb Naumenko <naumenko.gs@gmail.com>
This commit is contained in:
Jon Atack 2020-05-10 15:47:32 +02:00
parent 88d8b4e182
commit 83da576f44
No known key found for this signature in database
GPG Key ID: 4F5721B3D0E3921D

View File

@ -16,6 +16,7 @@
#include <crypto/sha256.h>
#include <netbase.h>
#include <net_permissions.h>
#include <protocol.h>
#include <random.h>
#include <scheduler.h>
#include <ui_interface.h>
@ -631,14 +632,14 @@ int CNode::GetSendVersion() const
int V1TransportDeserializer::readHeader(const char *pch, unsigned int nBytes)
{
// copy data to temporary parsing buffer
unsigned int nRemaining = 24 - nHdrPos;
unsigned int nRemaining = CMessageHeader::HEADER_SIZE - nHdrPos;
unsigned int nCopy = std::min(nRemaining, nBytes);
memcpy(&hdrbuf[nHdrPos], pch, nCopy);
nHdrPos += nCopy;
// if header incomplete, exit
if (nHdrPos < 24)
if (nHdrPos < CMessageHeader::HEADER_SIZE)
return nCopy;
// deserialize to CMessageHeader