From 3eac5e7cd1eda6ababb9af9cd72dae08d395993d Mon Sep 17 00:00:00 2001 From: dergoegge Date: Tue, 14 Mar 2023 17:48:32 +0100 Subject: [PATCH] [net] Add CNode helper for send byte accounting --- src/net.cpp | 2 +- src/net.h | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/net.cpp b/src/net.cpp index 384db5c014f..59a84f2fdf3 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2860,7 +2860,7 @@ void CConnman::PushMessage(CNode* pnode, CSerializedNetMsg&& msg) bool optimisticSend(pnode->vSendMsg.empty()); //log total amount of bytes per message type - pnode->mapSendBytesPerMsgType[msg.m_type] += nTotalSize; + pnode->AccountForSentBytes(msg.m_type, nTotalSize); pnode->nSendSize += nTotalSize; if (pnode->nSendSize > nSendBufferMaxSize) pnode->fPauseSend = true; diff --git a/src/net.h b/src/net.h index 7b1b7b4159f..67cae64ef6e 100644 --- a/src/net.h +++ b/src/net.h @@ -430,6 +430,13 @@ public: std::optional> PollMessage(size_t recv_flood_size) EXCLUSIVE_LOCKS_REQUIRED(!m_msg_process_queue_mutex); + /** Account for the total size of a sent message in the per msg type connection stats. */ + void AccountForSentBytes(const std::string& msg_type, size_t sent_bytes) + EXCLUSIVE_LOCKS_REQUIRED(cs_vSend) + { + mapSendBytesPerMsgType[msg_type] += sent_bytes; + } + bool IsOutboundOrBlockRelayConn() const { switch (m_conn_type) { case ConnectionType::OUTBOUND_FULL_RELAY: