mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-11 15:48:05 +00:00
net: set message deserialization version when it's actually time to deserialize
We'll soon no longer have access to vRecvMsg, and this is more intuitive anyway.
This commit is contained in:
parent
0e973d970a
commit
56212e20ac
@ -653,7 +653,7 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes, bool& complete
|
|||||||
// get current incomplete message, or create a new one
|
// get current incomplete message, or create a new one
|
||||||
if (vRecvMsg.empty() ||
|
if (vRecvMsg.empty() ||
|
||||||
vRecvMsg.back().complete())
|
vRecvMsg.back().complete())
|
||||||
vRecvMsg.push_back(CNetMessage(Params().MessageStart(), SER_NETWORK, nRecvVersion));
|
vRecvMsg.push_back(CNetMessage(Params().MessageStart(), SER_NETWORK, INIT_PROTO_VERSION));
|
||||||
|
|
||||||
CNetMessage& msg = vRecvMsg.back();
|
CNetMessage& msg = vRecvMsg.back();
|
||||||
|
|
||||||
|
@ -607,7 +607,7 @@ public:
|
|||||||
std::list<CNetMessage> vRecvMsg;
|
std::list<CNetMessage> vRecvMsg;
|
||||||
CCriticalSection cs_vRecvMsg;
|
CCriticalSection cs_vRecvMsg;
|
||||||
uint64_t nRecvBytes;
|
uint64_t nRecvBytes;
|
||||||
int nRecvVersion;
|
std::atomic<int> nRecvVersion;
|
||||||
|
|
||||||
int64_t nLastSend;
|
int64_t nLastSend;
|
||||||
int64_t nLastRecv;
|
int64_t nLastRecv;
|
||||||
@ -747,12 +747,13 @@ public:
|
|||||||
// requires LOCK(cs_vRecvMsg)
|
// requires LOCK(cs_vRecvMsg)
|
||||||
bool ReceiveMsgBytes(const char *pch, unsigned int nBytes, bool& complete);
|
bool ReceiveMsgBytes(const char *pch, unsigned int nBytes, bool& complete);
|
||||||
|
|
||||||
// requires LOCK(cs_vRecvMsg)
|
|
||||||
void SetRecvVersion(int nVersionIn)
|
void SetRecvVersion(int nVersionIn)
|
||||||
{
|
{
|
||||||
nRecvVersion = nVersionIn;
|
nRecvVersion = nVersionIn;
|
||||||
BOOST_FOREACH(CNetMessage &msg, vRecvMsg)
|
}
|
||||||
msg.SetVersion(nVersionIn);
|
int GetRecvVersion()
|
||||||
|
{
|
||||||
|
return nRecvVersion;
|
||||||
}
|
}
|
||||||
void SetSendVersion(int nVersionIn)
|
void SetSendVersion(int nVersionIn)
|
||||||
{
|
{
|
||||||
|
@ -2485,6 +2485,7 @@ bool ProcessMessages(CNode* pfrom, CConnman& connman, std::atomic<bool>& interru
|
|||||||
// at this point, any failure means we can delete the current message
|
// at this point, any failure means we can delete the current message
|
||||||
it++;
|
it++;
|
||||||
|
|
||||||
|
msg.SetVersion(pfrom->GetRecvVersion());
|
||||||
// Scan for message start
|
// Scan for message start
|
||||||
if (memcmp(msg.hdr.pchMessageStart, chainparams.MessageStart(), CMessageHeader::MESSAGE_START_SIZE) != 0) {
|
if (memcmp(msg.hdr.pchMessageStart, chainparams.MessageStart(), CMessageHeader::MESSAGE_START_SIZE) != 0) {
|
||||||
LogPrintf("PROCESSMESSAGE: INVALID MESSAGESTART %s peer=%d\n", SanitizeString(msg.hdr.GetCommand()), pfrom->id);
|
LogPrintf("PROCESSMESSAGE: INVALID MESSAGESTART %s peer=%d\n", SanitizeString(msg.hdr.GetCommand()), pfrom->id);
|
||||||
|
Loading…
Reference in New Issue
Block a user