tracing: pass if replaced by tx/pkg to tracepoint

The mempool:replaced tracepoint now reports either a txid or a
package hash (previously it always was a txid). To let users know
if a txid or package hash is passed, a boolean argument is added
the the tracepoint.

In the functional test, a ctypes.Structure class for MempoolReplaced
is introduced as Python warns the following when not explcitly
casting it to a ctype:

  Type: 'bool' not recognized. Please define the data with ctypes manually.
This commit is contained in:
0xb10c
2024-11-07 14:53:06 +01:00
committed by Suhas Daftuar
parent a4ec07f194
commit 5736d1ddac
3 changed files with 28 additions and 7 deletions

View File

@@ -1299,7 +1299,8 @@ void MemPoolAccept::FinalizeSubpackage(const ATMPArgs& args)
it->GetTxSize());
FeeFrac feerate{m_subpackage.m_total_modified_fees, int32_t(m_subpackage.m_total_vsize)};
uint256 tx_or_package_hash{};
if (m_subpackage.m_changeset->GetTxCount() == 1) {
const bool replaced_with_tx{m_subpackage.m_changeset->GetTxCount() == 1};
if (replaced_with_tx) {
const CTransaction& tx = m_subpackage.m_changeset->GetAddedTxn(0);
tx_or_package_hash = tx.GetHash();
log_string += strprintf("New tx %s (wtxid=%s, fees=%s, vsize=%s)",
@@ -1324,7 +1325,8 @@ void MemPoolAccept::FinalizeSubpackage(const ATMPArgs& args)
std::chrono::duration_cast<std::chrono::duration<std::uint64_t>>(it->GetTime()).count(),
tx_or_package_hash.data(),
feerate.size,
feerate.fee
feerate.fee,
replaced_with_tx
);
m_subpackage.m_replaced_transactions.push_back(it->GetSharedTx());
}