aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorTroy Giorshev <troygiorshev@gmail.com>2020-07-13 13:20:47 -0400
committerTroy Giorshev <troygiorshev@gmail.com>2021-01-23 15:58:42 -0500
commitf2a77ff97bec09dd5fcc043d8659d8ec5dfb87c2 (patch)
treefb44b69ac67e2183242dfd743aab011e611adb37 /src/net.h
parentdbf779d5deb04f55c6e8493ce4e12ed4628638f3 (diff)
downloadbitcoin-f2a77ff97bec09dd5fcc043d8659d8ec5dfb87c2.tar.xz
Add CaptureMessage
This commit adds the CaptureMessage function. This will later be called when any message is sent or received. The capture directory is fixed, in a new folder "message_capture" in the datadir. Peers will then have their own subfolders, named with their IP address and port, replacing colons with underscores to keep compatibility with Windows. Inside, received and sent messages will be captured into two binary files, msgs_recv.dat and msgs_sent.dat. e.g. message_capture/203.0.113.7_56072/msgs_recv.dat message_capture/203.0.113.7_56072/msgs_sent.dat The format has been designed as to result in a minimal performance impact. A parsing script is added in a later commit.
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/net.h b/src/net.h
index 087135a290..96d411bf29 100644
--- a/src/net.h
+++ b/src/net.h
@@ -20,6 +20,7 @@
#include <policy/feerate.h>
#include <protocol.h>
#include <random.h>
+#include <span.h>
#include <streams.h>
#include <sync.h>
#include <threadinterrupt.h>
@@ -75,6 +76,8 @@ static constexpr uint64_t DEFAULT_MAX_UPLOAD_TARGET = 0;
static const bool DEFAULT_BLOCKSONLY = false;
/** -peertimeout default */
static const int64_t DEFAULT_PEER_CONNECT_TIMEOUT = 60;
+/** Number of file descriptors required for message capture **/
+static const int NUM_FDS_MESSAGE_CAPTURE = 1;
static const bool DEFAULT_FORCEDNSSEED = false;
static const size_t DEFAULT_MAXRECEIVEBUFFER = 5 * 1000;
@@ -1239,6 +1242,9 @@ inline std::chrono::microseconds PoissonNextSend(std::chrono::microseconds now,
return std::chrono::microseconds{PoissonNextSend(now.count(), average_interval.count())};
}
+/** Dump binary message to file, with timestamp */
+void CaptureMessage(const CAddress& addr, const std::string& msg_type, const Span<const unsigned char>& data, bool is_incoming);
+
struct NodeEvictionCandidate
{
NodeId id;