Remove transport protocol knowhow from CNetMessage / net processing
This commit is contained in:
3 files changed
+5
-3
No files matched your search
+3
-2
@@ -601,7 +601,7 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes, bool& complete
|
|||||||
if (i == mapRecvBytesPerMsgCmd.end())
|
if (i == mapRecvBytesPerMsgCmd.end())
|
||||||
i = mapRecvBytesPerMsgCmd.find(NET_MESSAGE_COMMAND_OTHER);
|
i = mapRecvBytesPerMsgCmd.find(NET_MESSAGE_COMMAND_OTHER);
|
||||||
assert(i != mapRecvBytesPerMsgCmd.end());
|
assert(i != mapRecvBytesPerMsgCmd.end());
|
||||||
i->second += m_deserializer->hdr.nMessageSize + CMessageHeader::HEADER_SIZE;
|
i->second += msg.m_raw_message_size;
|
||||||
|
|
||||||
// push the message to the process queue,
|
// push the message to the process queue,
|
||||||
vRecvMsg.push_back(std::move(msg));
|
vRecvMsg.push_back(std::move(msg));
|
||||||
@@ -707,6 +707,7 @@ CNetMessage TransportDeserializer::GetMessage(const CMessageHeader::MessageStart
|
|||||||
// store command string, payload size
|
// store command string, payload size
|
||||||
msg.m_command = hdr.GetCommand();
|
msg.m_command = hdr.GetCommand();
|
||||||
msg.m_message_size = hdr.nMessageSize;
|
msg.m_message_size = hdr.nMessageSize;
|
||||||
|
msg.m_raw_message_size = hdr.nMessageSize + CMessageHeader::HEADER_SIZE;
|
||||||
|
|
||||||
msg.m_valid_checksum = (memcmp(hash.begin(), hdr.pchChecksum, CMessageHeader::CHECKSUM_SIZE) == 0);
|
msg.m_valid_checksum = (memcmp(hash.begin(), hdr.pchChecksum, CMessageHeader::CHECKSUM_SIZE) == 0);
|
||||||
if (!msg.m_valid_checksum) {
|
if (!msg.m_valid_checksum) {
|
||||||
@@ -1377,7 +1378,7 @@ void CConnman::SocketHandler()
|
|||||||
for (; it != pnode->vRecvMsg.end(); ++it) {
|
for (; it != pnode->vRecvMsg.end(); ++it) {
|
||||||
// vRecvMsg contains only completed CNetMessage
|
// vRecvMsg contains only completed CNetMessage
|
||||||
// the single possible partially deserialized message are held by TransportDeserializer
|
// the single possible partially deserialized message are held by TransportDeserializer
|
||||||
nSizeAdded += it->m_recv.size() + CMessageHeader::HEADER_SIZE;
|
nSizeAdded += it->m_raw_message_size;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
LOCK(pnode->cs_vProcessMsg);
|
LOCK(pnode->cs_vProcessMsg);
|
||||||
|
|||||||
@@ -621,6 +621,7 @@ public:
|
|||||||
bool m_valid_header = false;
|
bool m_valid_header = false;
|
||||||
bool m_valid_checksum = false;
|
bool m_valid_checksum = false;
|
||||||
uint32_t m_message_size = 0; // size of the payload
|
uint32_t m_message_size = 0; // size of the payload
|
||||||
|
uint32_t m_raw_message_size = 0; // used wire size of the message (including header/checksum)
|
||||||
std::string m_command;
|
std::string m_command;
|
||||||
|
|
||||||
CNetMessage(const CDataStream& recv_in) : m_recv(std::move(recv_in)) {}
|
CNetMessage(const CDataStream& recv_in) : m_recv(std::move(recv_in)) {}
|
||||||
|
|||||||
@@ -3260,7 +3260,7 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
|
|||||||
return false;
|
return false;
|
||||||
// Just take one message
|
// Just take one message
|
||||||
msgs.splice(msgs.begin(), pfrom->vProcessMsg, pfrom->vProcessMsg.begin());
|
msgs.splice(msgs.begin(), pfrom->vProcessMsg, pfrom->vProcessMsg.begin());
|
||||||
pfrom->nProcessQueueSize -= msgs.front().m_recv.size() + CMessageHeader::HEADER_SIZE;
|
pfrom->nProcessQueueSize -= msgs.front().m_raw_message_size;
|
||||||
pfrom->fPauseRecv = pfrom->nProcessQueueSize > connman->GetReceiveFloodSize();
|
pfrom->fPauseRecv = pfrom->nProcessQueueSize > connman->GetReceiveFloodSize();
|
||||||
fMoreWork = !pfrom->vProcessMsg.empty();
|
fMoreWork = !pfrom->vProcessMsg.empty();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user