Changeset View
Changeset View
Standalone View
Standalone View
src/net.cpp
Show All 10 Lines | |||||
#include <banman.h> | #include <banman.h> | ||||
#include <clientversion.h> | #include <clientversion.h> | ||||
#include <config.h> | #include <config.h> | ||||
#include <consensus/consensus.h> | #include <consensus/consensus.h> | ||||
#include <crypto/sha256.h> | #include <crypto/sha256.h> | ||||
#include <netbase.h> | #include <netbase.h> | ||||
#include <node/ui_interface.h> | #include <node/ui_interface.h> | ||||
#include <protocol.h> | |||||
#include <random.h> | #include <random.h> | ||||
#include <scheduler.h> | #include <scheduler.h> | ||||
#include <util/strencodings.h> | #include <util/strencodings.h> | ||||
#include <util/translation.h> | #include <util/translation.h> | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
#include <cstring> | #include <cstring> | ||||
#else | #else | ||||
▲ Show 20 Lines • Show All 643 Lines • ▼ Show 20 Lines | if (nSendVersion == 0) { | ||||
return INIT_PROTO_VERSION; | return INIT_PROTO_VERSION; | ||||
} | } | ||||
return nSendVersion; | return nSendVersion; | ||||
} | } | ||||
int V1TransportDeserializer::readHeader(const Config &config, const char *pch, | int V1TransportDeserializer::readHeader(const Config &config, const char *pch, | ||||
uint32_t nBytes) { | uint32_t nBytes) { | ||||
// copy data to temporary parsing buffer | // copy data to temporary parsing buffer | ||||
uint32_t nRemaining = 24 - nHdrPos; | uint32_t nRemaining = CMessageHeader::HEADER_SIZE - nHdrPos; | ||||
uint32_t nCopy = std::min(nRemaining, nBytes); | uint32_t nCopy = std::min(nRemaining, nBytes); | ||||
memcpy(&hdrbuf[nHdrPos], pch, nCopy); | memcpy(&hdrbuf[nHdrPos], pch, nCopy); | ||||
nHdrPos += nCopy; | nHdrPos += nCopy; | ||||
// if header incomplete, exit | // if header incomplete, exit | ||||
if (nHdrPos < 24) { | if (nHdrPos < CMessageHeader::HEADER_SIZE) { | ||||
return nCopy; | return nCopy; | ||||
} | } | ||||
// deserialize to CMessageHeader | // deserialize to CMessageHeader | ||||
try { | try { | ||||
hdrbuf >> hdr; | hdrbuf >> hdr; | ||||
} catch (const std::exception &) { | } catch (const std::exception &) { | ||||
return -1; | return -1; | ||||
▲ Show 20 Lines • Show All 2,488 Lines • Show Last 20 Lines |