|
|
@ -689,6 +689,33 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes, bool& complete |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CNode::SetSendVersion(int nVersionIn) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Send version may only be changed in the version message, and
|
|
|
|
|
|
|
|
// only one version message is allowed per session. We can therefore
|
|
|
|
|
|
|
|
// treat this value as const and even atomic as long as it's only used
|
|
|
|
|
|
|
|
// once a version message has been successfully processed. Any attempt to
|
|
|
|
|
|
|
|
// set this twice is an error.
|
|
|
|
|
|
|
|
if (nSendVersion != 0) { |
|
|
|
|
|
|
|
error("Send version already set for node: %i. Refusing to change from %i to %i", id, nSendVersion, nVersionIn); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
nSendVersion = nVersionIn; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int CNode::GetSendVersion() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// The send version should always be explicitly set to
|
|
|
|
|
|
|
|
// INIT_PROTO_VERSION rather than using this value until SetSendVersion
|
|
|
|
|
|
|
|
// has been called.
|
|
|
|
|
|
|
|
if (nSendVersion == 0) { |
|
|
|
|
|
|
|
error("Requesting unset send version for node: %i. Using %i", id, INIT_PROTO_VERSION); |
|
|
|
|
|
|
|
return INIT_PROTO_VERSION; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return nSendVersion; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int CNetMessage::readHeader(const char *pch, unsigned int nBytes) |
|
|
|
int CNetMessage::readHeader(const char *pch, unsigned int nBytes) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// copy data to temporary parsing buffer
|
|
|
|
// copy data to temporary parsing buffer
|
|
|
|