diff options
author | ismaelsadeeq <ask4ismailsadiq@gmail.com> | 2023-11-03 12:34:29 +0100 |
---|---|---|
committer | ismaelsadeeq <ask4ismailsadiq@gmail.com> | 2023-11-22 11:48:21 +0100 |
commit | bfcd401368fc0dc43827a8969a37b7e038d5ca79 (patch) | |
tree | 72b1323223b683471693f6101fa1f1f99057f831 /src/kernel | |
parent | 0889e07987294d4ef2814abfca16d8e2a0c5f541 (diff) |
CValidationInterface, mempool: add new callback to `CValidationInterface`
This commit adds a new callback `MempoolTransactionsRemovedForBlock` which notify
its listeners of the transactions that are removed from the mempool because a new
block is connected, along with the block height the transactions were removed.
The transactions are in `RemovedMempoolTransactionInfo` format.
`CTransactionRef`, base fee, virtual size, and height which the transaction was added
to the mempool are all members of the struct called `RemovedMempoolTransactionInfo`.
A struct `NewMempoolTransactionInfo`, which has fields similar to `RemovedMempoolTransactionInfo`,
will be added in a later commit, create a struct `TransactionInfo` with all similar fields.
They can both have a member with type `TransactionInfo`.
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/mempool_entry.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/kernel/mempool_entry.h b/src/kernel/mempool_entry.h index 7c905ca4f4..ce32fe20dc 100644 --- a/src/kernel/mempool_entry.h +++ b/src/kernel/mempool_entry.h @@ -178,4 +178,34 @@ public: using CTxMemPoolEntryRef = CTxMemPoolEntry::CTxMemPoolEntryRef; +struct TransactionInfo { + const CTransactionRef m_tx; + /* The fee the transaction paid */ + const CAmount m_fee; + /** + * The virtual transaction size. + * + * This is a policy field which considers the sigop cost of the + * transaction as well as its weight, and reinterprets it as bytes. + * + * It is the primary metric by which the mining algorithm selects + * transactions. + */ + const int64_t m_virtual_transaction_size; + /* The block height the transaction entered the mempool */ + const unsigned int txHeight; + + TransactionInfo(const CTransactionRef& tx, const CAmount& fee, const int64_t vsize, const unsigned int height) + : m_tx{tx}, + m_fee{fee}, + m_virtual_transaction_size{vsize}, + txHeight{height} {} +}; + +struct RemovedMempoolTransactionInfo { + TransactionInfo info; + explicit RemovedMempoolTransactionInfo(const CTxMemPoolEntry& entry) + : info{entry.GetSharedTx(), entry.GetFee(), entry.GetTxSize(), entry.GetHeight()} {} +}; + #endif // BITCOIN_KERNEL_MEMPOOL_ENTRY_H |