tracing: Tracepoints for in- and outbound P2P msgs

Can be used to monitor in- and outbound node traffic.

Based on ealier work by jb55.

Co-authored-by: William Casarin <jb55@jb55.com>
This commit is contained in:
0xb10c
2021-05-20 16:54:54 +02:00
parent 469b71ae62
commit 4224dec22b
7 changed files with 639 additions and 1 deletions

View File

@@ -34,6 +34,7 @@
#include <util/check.h> // For NDEBUG compile time check
#include <util/strencodings.h>
#include <util/system.h>
#include <util/trace.h>
#include <validation.h>
#include <algorithm>
@@ -4052,6 +4053,15 @@ bool PeerManagerImpl::ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt
}
CNetMessage& msg(msgs.front());
TRACE6(net, inbound_message,
pfrom->GetId(),
pfrom->GetAddrName().c_str(),
pfrom->ConnectionTypeAsString().c_str(),
msg.m_command.c_str(),
msg.m_recv.size(),
msg.m_recv.data()
);
if (gArgs.GetBoolArg("-capturemessages", false)) {
CaptureMessage(pfrom->addr, msg.m_command, MakeUCharSpan(msg.m_recv), /* incoming */ true);
}