Skip to content

Commit

Permalink
Clean PushMessage and ProcessMessages
Browse files Browse the repository at this point in the history
This brings PushMessage and ProcessMessages further in line with the
style guide by fixing their if statements.

LogMessage is later called, inside an if statement, inside both of these
methods.
  • Loading branch information
troygiorshev committed Jan 18, 2021
1 parent bc51b99 commit dbf779d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
12 changes: 4 additions & 8 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2879,18 +2879,14 @@ void CConnman::PushMessage(CNode* pnode, CSerializedNetMsg&& msg)
pnode->mapSendBytesPerMsgCmd[msg.m_type] += nTotalSize;
pnode->nSendSize += nTotalSize;

if (pnode->nSendSize > nSendBufferMaxSize)
pnode->fPauseSend = true;
if (pnode->nSendSize > nSendBufferMaxSize) pnode->fPauseSend = true;
pnode->vSendMsg.push_back(std::move(serializedHeader));
if (nMessageSize)
pnode->vSendMsg.push_back(std::move(msg.data));
if (nMessageSize) pnode->vSendMsg.push_back(std::move(msg.data));

// If write queue empty, attempt "optimistic write"
if (optimisticSend == true)
nBytesSent = SocketSendData(*pnode);
if (optimisticSend) nBytesSent = SocketSendData(*pnode);
}
if (nBytesSent)
RecordBytesSent(nBytesSent);
if (nBytesSent) RecordBytesSent(nBytesSent);
}

bool CConnman::ForNode(NodeId id, std::function<bool(CNode* pnode)> func)
Expand Down
6 changes: 2 additions & 4 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4028,14 +4028,12 @@ bool PeerManagerImpl::ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt
}

// Don't bother if send buffer is too full to respond anyway
if (pfrom->fPauseSend)
return false;
if (pfrom->fPauseSend) return false;

std::list<CNetMessage> msgs;
{
LOCK(pfrom->cs_vProcessMsg);
if (pfrom->vProcessMsg.empty())
return false;
if (pfrom->vProcessMsg.empty()) return false;
// Just take one message
msgs.splice(msgs.begin(), pfrom->vProcessMsg, pfrom->vProcessMsg.begin());
pfrom->nProcessQueueSize -= msgs.front().m_raw_message_size;
Expand Down

0 comments on commit dbf779d

Please sign in to comment.