aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordergoegge <n.goeggi@gmail.com>2023-03-14 17:48:32 +0100
committerdergoegge <n.goeggi@gmail.com>2023-03-22 13:18:57 +0100
commit3eac5e7cd1eda6ababb9af9cd72dae08d395993d (patch)
tree428a3867043c8e81cb8bb8d84345de588cecfd67 /src
parent60441a3432df10f5d7c15c09c9569f27a793625b (diff)
[net] Add CNode helper for send byte accounting
Diffstat (limited to 'src')
-rw-r--r--src/net.cpp2
-rw-r--r--src/net.h7
2 files changed, 8 insertions, 1 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 384db5c014..59a84f2fdf 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 7b1b7b4159..67cae64ef6 100644
--- a/src/net.h
+++ b/src/net.h
@@ -430,6 +430,13 @@ public:
std::optional<std::pair<CNetMessage, bool>> 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: