Skip to content

Commit 3eac5e7

Browse files
committed
[net] Add CNode helper for send byte accounting
1 parent 60441a3 commit 3eac5e7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2860,7 +2860,7 @@ void CConnman::PushMessage(CNode* pnode, CSerializedNetMsg&& msg)
28602860
bool optimisticSend(pnode->vSendMsg.empty());
28612861

28622862
//log total amount of bytes per message type
2863-
pnode->mapSendBytesPerMsgType[msg.m_type] += nTotalSize;
2863+
pnode->AccountForSentBytes(msg.m_type, nTotalSize);
28642864
pnode->nSendSize += nTotalSize;
28652865

28662866
if (pnode->nSendSize > nSendBufferMaxSize) pnode->fPauseSend = true;

src/net.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,13 @@ class CNode
430430
std::optional<std::pair<CNetMessage, bool>> PollMessage(size_t recv_flood_size)
431431
EXCLUSIVE_LOCKS_REQUIRED(!m_msg_process_queue_mutex);
432432

433+
/** Account for the total size of a sent message in the per msg type connection stats. */
434+
void AccountForSentBytes(const std::string& msg_type, size_t sent_bytes)
435+
EXCLUSIVE_LOCKS_REQUIRED(cs_vSend)
436+
{
437+
mapSendBytesPerMsgType[msg_type] += sent_bytes;
438+
}
439+
433440
bool IsOutboundOrBlockRelayConn() const {
434441
switch (m_conn_type) {
435442
case ConnectionType::OUTBOUND_FULL_RELAY:

0 commit comments

Comments
 (0)