aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTroy Giorshev <troygiorshev@gmail.com>2020-07-13 14:00:03 -0400
committerTroy Giorshev <troygiorshev@gmail.com>2021-01-23 15:58:42 -0500
commit4d1a582549bc982d55e24585b0ba06f92f21e9da (patch)
tree926a3e2d20a05a4ad93e33913310aec9a001a9fa /src
parentf2a77ff97bec09dd5fcc043d8659d8ec5dfb87c2 (diff)
downloadbitcoin-4d1a582549bc982d55e24585b0ba06f92f21e9da.tar.xz
Call CaptureMessage at appropriate locations
These calls are toggled by a debug-only "capturemessages" flag. Default disabled.
Diffstat (limited to 'src')
-rw-r--r--src/init.cpp1
-rw-r--r--src/net.cpp3
-rw-r--r--src/net_processing.cpp4
3 files changed, 8 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 3ab6263813..e16f0e8c83 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -521,6 +521,7 @@ void SetupServerArgs(NodeContext& node)
argsman.AddArg("-limitdescendantcount=<n>", strprintf("Do not accept transactions if any ancestor would have <n> or more in-mempool descendants (default: %u)", DEFAULT_DESCENDANT_LIMIT), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-limitdescendantsize=<n>", strprintf("Do not accept transactions if any ancestor would have more than <n> kilobytes of in-mempool descendants (default: %u).", DEFAULT_DESCENDANT_SIZE_LIMIT), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-addrmantest", "Allows to test address relay on localhost", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
+ argsman.AddArg("-capturemessages", "Capture all P2P messages to disk", ArgsManager::ALLOW_BOOL | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-debug=<category>", "Output debugging information (default: -nodebug, supplying <category> is optional). "
"If <category> is not supplied or if <category> = 1, output all debugging information. <category> can be: " + LogInstance().LogCategoriesString() + ".",
ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
diff --git a/src/net.cpp b/src/net.cpp
index 29529d54ca..81f014d932 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -2864,6 +2864,9 @@ void CConnman::PushMessage(CNode* pnode, CSerializedNetMsg&& msg)
{
size_t nMessageSize = msg.data.size();
LogPrint(BCLog::NET, "sending %s (%d bytes) peer=%d\n", SanitizeString(msg.m_type), nMessageSize, pnode->GetId());
+ if (gArgs.GetBoolArg("-capturemessages", false)) {
+ CaptureMessage(pnode->addr, msg.m_type, msg.data, /* incoming */ false);
+ }
// make sure we use the appropriate network transport format
std::vector<unsigned char> serializedHeader;
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 7d89d3ea6e..d0a743e81c 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -4042,6 +4042,10 @@ bool PeerManagerImpl::ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt
}
CNetMessage& msg(msgs.front());
+ if (gArgs.GetBoolArg("-capturemessages", false)) {
+ CaptureMessage(pfrom->addr, msg.m_command, MakeUCharSpan(msg.m_recv), /* incoming */ true);
+ }
+
msg.SetVersion(pfrom->GetCommonVersion());
const std::string& msg_type = msg.m_command;