merge bitcoin#26888: simplify the call to vProcessMsg.splice()

This commit is contained in:
Kittywhiskers Van Gogh 2023-01-13 14:44:23 +01:00
parent d9e56f3e78
commit d3f5b3881b
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
2 changed files with 6 additions and 8 deletions

View File

@ -2097,15 +2097,14 @@ size_t CConnman::SocketRecvData(CNode *pnode)
RecordBytesRecv(nBytes); RecordBytesRecv(nBytes);
if (notify) { if (notify) {
size_t nSizeAdded = 0; size_t nSizeAdded = 0;
auto it(pnode->vRecvMsg.begin()); for (const auto& msg : pnode->vRecvMsg) {
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_raw_message_size; nSizeAdded += msg.m_raw_message_size;
} }
{ {
LOCK(pnode->cs_vProcessMsg); LOCK(pnode->cs_vProcessMsg);
pnode->vProcessMsg.splice(pnode->vProcessMsg.end(), pnode->vRecvMsg, pnode->vRecvMsg.begin(), it); pnode->vProcessMsg.splice(pnode->vProcessMsg.end(), pnode->vRecvMsg);
pnode->nProcessQueueSize += nSizeAdded; pnode->nProcessQueueSize += nSizeAdded;
pnode->fPauseRecv = pnode->nProcessQueueSize > nReceiveFloodSize; pnode->fPauseRecv = pnode->nProcessQueueSize > nReceiveFloodSize;
} }

View File

@ -69,15 +69,14 @@ void ConnmanTestMsg::NodeReceiveMsgBytes(CNode& node, Span<const uint8_t> msg_by
assert(node.ReceiveMsgBytes(msg_bytes, complete)); assert(node.ReceiveMsgBytes(msg_bytes, complete));
if (complete) { if (complete) {
size_t nSizeAdded = 0; size_t nSizeAdded = 0;
auto it(node.vRecvMsg.begin()); for (const auto& msg : node.vRecvMsg) {
for (; it != node.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_raw_message_size; nSizeAdded += msg.m_raw_message_size;
} }
{ {
LOCK(node.cs_vProcessMsg); LOCK(node.cs_vProcessMsg);
node.vProcessMsg.splice(node.vProcessMsg.end(), node.vRecvMsg, node.vRecvMsg.begin(), it); node.vProcessMsg.splice(node.vProcessMsg.end(), node.vRecvMsg);
node.nProcessQueueSize += nSizeAdded; node.nProcessQueueSize += nSizeAdded;
node.fPauseRecv = node.nProcessQueueSize > nReceiveFloodSize; node.fPauseRecv = node.nProcessQueueSize > nReceiveFloodSize;
} }