Bitcoin Core 28.99.0
P2P Digital Currency
|
A minimal version of BlockAssembler, using the same ancestor set scoring algorithm. More...
#include <mini_miner.h>
Public Member Functions | |
bool | IsReadyToCalculate () const |
Returns true if CalculateBumpFees may be called, false if not. More... | |
void | BuildMockTemplate (std::optional< CFeeRate > target_feerate) |
Build a block template until the target feerate is hit. More... | |
std::set< uint256 > | GetMockTemplateTxids () const |
Returns set of txids in the block template if one has been constructed. More... | |
MiniMiner (const CTxMemPool &mempool, const std::vector< COutPoint > &outpoints) | |
Constructor that takes a list of outpoints that may or may not belong to transactions in the mempool. More... | |
MiniMiner (const std::vector< MiniMinerMempoolEntry > &manual_entries, const std::map< Txid, std::set< Txid > > &descendant_caches) | |
Constructor in which the MiniMinerMempoolEntry entries have been constructed manually. More... | |
std::map< COutPoint, CAmount > | CalculateBumpFees (const CFeeRate &target_feerate) |
Construct a new block template and, for each outpoint corresponding to a transaction that did not make it into the block, calculate the cost of bumping those transactions (and their ancestors) to the minimum feerate. More... | |
std::optional< CAmount > | CalculateTotalBumpFees (const CFeeRate &target_feerate) |
Construct a new block template and, calculate the cost of bumping all transactions that did not make it into the block to the target feerate. More... | |
std::map< Txid, uint32_t > | Linearize () |
Construct a new block template with all of the transactions and calculate the order in which they are selected. More... | |
Private Types | |
using | MockEntryMap = decltype(m_entries_by_txid) |
Private Member Functions | |
void | DeleteAncestorPackage (const std::set< MockEntryMap::iterator, IteratorComparator > &ancestors) |
Consider this ancestor package "mined" so remove all these entries from our data structures. More... | |
void | SanityCheck () const |
Perform some checks. More... | |
Private Attributes | |
bool | m_ready_to_calculate {true} |
std::set< uint256 > | m_to_be_replaced |
std::map< uint256, std::vector< COutPoint > > | m_requested_outpoints_by_txid |
std::map< Txid, uint32_t > | m_inclusion_order |
std::map< COutPoint, CAmount > | m_bump_fees |
std::set< uint256 > | m_in_block |
CAmount | m_total_fees {0} |
int32_t | m_total_vsize {0} |
std::map< uint256, MiniMinerMempoolEntry > | m_entries_by_txid |
Main data structure holding the entries, can be indexed by txid. More... | |
std::vector< MockEntryMap::iterator > | m_entries |
Vector of entries, can be sorted by ancestor feerate. More... | |
std::map< uint256, std::vector< MockEntryMap::iterator > > | m_descendant_set_by_txid |
Map of txid to its descendants. More... | |
A minimal version of BlockAssembler, using the same ancestor set scoring algorithm.
Allows us to run this algorithm on a limited set of transactions (e.g. subset of mempool or transactions that are not yet in mempool) instead of the entire mempool, ignoring consensus rules. Callers may use this to:
Definition at line 78 of file mini_miner.h.
|
private |
Definition at line 109 of file mini_miner.h.
node::MiniMiner::MiniMiner | ( | const CTxMemPool & | mempool, |
const std::vector< COutPoint > & | outpoints | ||
) |
Constructor that takes a list of outpoints that may or may not belong to transactions in the mempool.
Copies out information about the relevant transactions in the mempool into MiniMinerMempoolEntrys.
Definition at line 23 of file mini_miner.cpp.
node::MiniMiner::MiniMiner | ( | const std::vector< MiniMinerMempoolEntry > & | manual_entries, |
const std::map< Txid, std::set< Txid > > & | descendant_caches | ||
) |
Constructor in which the MiniMinerMempoolEntry entries have been constructed manually.
It is assumed that all entries are unique and their values are correct, otherwise results computed by MiniMiner may be incorrect. Callers should check IsReadyToCalculate() after construction.
[in] | descendant_caches | A map from each transaction to the set of txids of this transaction's descendant set, including itself. Each tx in manual_entries must have a corresponding entry in this map, and all of the txids in a descendant set must correspond to a tx in manual_entries. |
Definition at line 135 of file mini_miner.cpp.
void node::MiniMiner::BuildMockTemplate | ( | std::optional< CFeeRate > | target_feerate | ) |
Build a block template until the target feerate is hit.
If target_feerate is not given, builds a block template until all transactions have been selected.
Definition at line 248 of file mini_miner.cpp.
std::map< COutPoint, CAmount > node::MiniMiner::CalculateBumpFees | ( | const CFeeRate & | target_feerate | ) |
Construct a new block template and, for each outpoint corresponding to a transaction that did not make it into the block, calculate the cost of bumping those transactions (and their ancestors) to the minimum feerate.
Returns a map from outpoint to bump fee, or an empty map if they cannot be calculated.
Definition at line 313 of file mini_miner.cpp.
Construct a new block template and, calculate the cost of bumping all transactions that did not make it into the block to the target feerate.
Returns the total bump fee, or std::nullopt if it cannot be calculated.
Definition at line 393 of file mini_miner.cpp.
|
private |
Consider this ancestor package "mined" so remove all these entries from our data structures.
Definition at line 201 of file mini_miner.cpp.
|
inline |
Returns set of txids in the block template if one has been constructed.
Definition at line 132 of file mini_miner.h.
|
inline |
Returns true if CalculateBumpFees may be called, false if not.
Definition at line 125 of file mini_miner.h.
std::map< Txid, uint32_t > node::MiniMiner::Linearize | ( | ) |
Construct a new block template with all of the transactions and calculate the order in which they are selected.
Returns the sequence number (lower = selected earlier) with which each transaction was selected, indexed by txid, or an empty map if it cannot be calculated.
Definition at line 307 of file mini_miner.cpp.
|
private |
Perform some checks.
Definition at line 234 of file mini_miner.cpp.
Definition at line 98 of file mini_miner.h.
|
private |
|
private |
Vector of entries, can be sorted by ancestor feerate.
Definition at line 112 of file mini_miner.h.
|
private |
Main data structure holding the entries, can be indexed by txid.
Definition at line 108 of file mini_miner.h.
|
private |
Definition at line 101 of file mini_miner.h.
|
private |
Definition at line 96 of file mini_miner.h.
|
private |
Definition at line 82 of file mini_miner.h.
Definition at line 91 of file mini_miner.h.
|
private |
Definition at line 86 of file mini_miner.h.
|
private |
Definition at line 104 of file mini_miner.h.
|
private |
Definition at line 105 of file mini_miner.h.