Bitcoin Core  25.99.0
P2P Digital Currency
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
node::MiniMiner Class Reference

A minimal version of BlockAssembler. More...

#include <mini_miner.h>

Public Member Functions

bool IsReadyToCalculate () const
 Returns true if CalculateBumpFees may be called, false if not. More...
 
void BuildMockTemplate (const CFeeRate &target_feerate)
 Build a block template until the target feerate is hit. More...
 
std::set< uint256GetMockTemplateTxids () const
 Returns set of txids in the block template if one has been constructed. More...
 
 MiniMiner (const CTxMemPool &mempool, const std::vector< COutPoint > &outpoints)
 
std::map< COutPoint, CAmountCalculateBumpFees (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< CAmountCalculateTotalBumpFees (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...
 

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< uint256m_to_be_replaced
 
std::map< uint256, std::vector< COutPoint > > m_requested_outpoints_by_txid
 
std::map< COutPoint, CAmountm_bump_fees
 
std::set< uint256m_in_block
 
CAmount m_total_fees {0}
 
int32_t m_total_vsize {0}
 
std::map< uint256, MiniMinerMempoolEntrym_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...
 

Detailed Description

A minimal version of BlockAssembler.

Allows us to run the mining algorithm on a subset of mempool transactions, ignoring consensus rules, to calculate mining scores.

Definition at line 55 of file mini_miner.h.

Member Typedef Documentation

◆ MockEntryMap

Definition at line 82 of file mini_miner.h.

Constructor & Destructor Documentation

◆ MiniMiner()

node::MiniMiner::MiniMiner ( const CTxMemPool mempool,
const std::vector< COutPoint > &  outpoints 
)

Definition at line 20 of file mini_miner.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ BuildMockTemplate()

void node::MiniMiner::BuildMockTemplate ( const CFeeRate target_feerate)

Build a block template until the target feerate is hit.

Definition at line 207 of file mini_miner.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CalculateBumpFees()

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 251 of file mini_miner.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CalculateTotalBumpFees()

std::optional< CAmount > node::MiniMiner::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.

Returns the total bump fee, or std::nullopt if it cannot be calculated.

Definition at line 331 of file mini_miner.cpp.

Here is the call graph for this function:

◆ DeleteAncestorPackage()

void node::MiniMiner::DeleteAncestorPackage ( const std::set< MockEntryMap::iterator, IteratorComparator > &  ancestors)
private

Consider this ancestor package "mined" so remove all these entries from our data structures.

Definition at line 159 of file mini_miner.cpp.

Here is the caller graph for this function:

◆ GetMockTemplateTxids()

std::set<uint256> node::MiniMiner::GetMockTemplateTxids ( ) const
inline

Returns set of txids in the block template if one has been constructed.

Definition at line 104 of file mini_miner.h.

◆ IsReadyToCalculate()

bool node::MiniMiner::IsReadyToCalculate ( ) const
inline

Returns true if CalculateBumpFees may be called, false if not.

Definition at line 98 of file mini_miner.h.

Here is the caller graph for this function:

◆ SanityCheck()

void node::MiniMiner::SanityCheck ( ) const
private

Perform some checks.

Definition at line 193 of file mini_miner.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ m_bump_fees

std::map<COutPoint, CAmount> node::MiniMiner::m_bump_fees
private

Definition at line 71 of file mini_miner.h.

◆ m_descendant_set_by_txid

std::map<uint256, std::vector<MockEntryMap::iterator> > node::MiniMiner::m_descendant_set_by_txid
private

Map of txid to its descendants.

Should be inclusive.

Definition at line 88 of file mini_miner.h.

◆ m_entries

std::vector<MockEntryMap::iterator> node::MiniMiner::m_entries
private

Vector of entries, can be sorted by ancestor feerate.

Definition at line 85 of file mini_miner.h.

◆ m_entries_by_txid

std::map<uint256, MiniMinerMempoolEntry> node::MiniMiner::m_entries_by_txid
private

Main data structure holding the entries, can be indexed by txid.

Definition at line 81 of file mini_miner.h.

◆ m_in_block

std::set<uint256> node::MiniMiner::m_in_block
private

Definition at line 74 of file mini_miner.h.

◆ m_ready_to_calculate

bool node::MiniMiner::m_ready_to_calculate {true}
private

Definition at line 59 of file mini_miner.h.

◆ m_requested_outpoints_by_txid

std::map<uint256, std::vector<COutPoint> > node::MiniMiner::m_requested_outpoints_by_txid
private

Definition at line 68 of file mini_miner.h.

◆ m_to_be_replaced

std::set<uint256> node::MiniMiner::m_to_be_replaced
private

Definition at line 63 of file mini_miner.h.

◆ m_total_fees

CAmount node::MiniMiner::m_total_fees {0}
private

Definition at line 77 of file mini_miner.h.

◆ m_total_vsize

int32_t node::MiniMiner::m_total_vsize {0}
private

Definition at line 78 of file mini_miner.h.


The documentation for this class was generated from the following files: