Skip to content

Commit 4d1a582

Browse files
committed
Call CaptureMessage at appropriate locations
These calls are toggled by a debug-only "capturemessages" flag. Default disabled.
1 parent f2a77ff commit 4d1a582

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/init.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ void SetupServerArgs(NodeContext& node)
521521
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);
522522
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);
523523
argsman.AddArg("-addrmantest", "Allows to test address relay on localhost", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
524+
argsman.AddArg("-capturemessages", "Capture all P2P messages to disk", ArgsManager::ALLOW_BOOL | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
524525
argsman.AddArg("-debug=<category>", "Output debugging information (default: -nodebug, supplying <category> is optional). "
525526
"If <category> is not supplied or if <category> = 1, output all debugging information. <category> can be: " + LogInstance().LogCategoriesString() + ".",
526527
ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);

src/net.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2864,6 +2864,9 @@ void CConnman::PushMessage(CNode* pnode, CSerializedNetMsg&& msg)
28642864
{
28652865
size_t nMessageSize = msg.data.size();
28662866
LogPrint(BCLog::NET, "sending %s (%d bytes) peer=%d\n", SanitizeString(msg.m_type), nMessageSize, pnode->GetId());
2867+
if (gArgs.GetBoolArg("-capturemessages", false)) {
2868+
CaptureMessage(pnode->addr, msg.m_type, msg.data, /* incoming */ false);
2869+
}
28672870

28682871
// make sure we use the appropriate network transport format
28692872
std::vector<unsigned char> serializedHeader;

src/net_processing.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4042,6 +4042,10 @@ bool PeerManagerImpl::ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt
40424042
}
40434043
CNetMessage& msg(msgs.front());
40444044

4045+
if (gArgs.GetBoolArg("-capturemessages", false)) {
4046+
CaptureMessage(pfrom->addr, msg.m_command, MakeUCharSpan(msg.m_recv), /* incoming */ true);
4047+
}
4048+
40454049
msg.SetVersion(pfrom->GetCommonVersion());
40464050
const std::string& msg_type = msg.m_command;
40474051

0 commit comments

Comments
 (0)