6 #ifndef BITCOIN_NODE_MINER_H
7 #define BITCOIN_NODE_MINER_H
11 #include <txmempool.h>
17 #include <boost/multi_index/ordered_index.hpp>
18 #include <boost/multi_index_container.hpp>
88 if (a->GetCountWithAncestors() != b->GetCountWithAncestors()) {
89 return a->GetCountWithAncestors() < b->GetCountWithAncestors();
95 typedef boost::multi_index_container<
96 CTxMemPoolModifiedEntry,
97 boost::multi_index::indexed_by<
98 boost::multi_index::ordered_unique<
100 CompareCTxMemPoolIter
103 boost::multi_index::ordered_non_unique<
105 boost::multi_index::tag<ancestor_score>,
106 boost::multi_index::identity<CTxMemPoolModifiedEntry>,
112 typedef indexed_modified_transaction_set::nth_index<0>::type::iterator
modtxiter;
113 typedef indexed_modified_transaction_set::index<ancestor_score>::type::iterator
modtxscoreiter;
188 bool TestPackage(uint64_t packageSize, int64_t packageSigOpsCost)
const;
int64_t CAmount
Amount in satoshis (Can be negative)
const CChainParams & Params()
Return the currently selected parameters.
The block chain is a tree shaped structure starting with the genesis block at the root,...
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Fee rate in satoshis per kilovirtualbyte: CAmount / kvB.
Serialized script, used inside transaction inputs and outputs.
The basic transaction that is broadcasted on the network and contained in blocks.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
std::set< txiter, CompareIteratorByHash > setEntries
indexed_transaction_set::nth_index< 0 >::type::const_iterator txiter
Chainstate stores and provides an API to update our local knowledge of the current best chain.
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Generate a new block, without valid proof-of-work.
Chainstate & m_chainstate
void onlyUnconfirmed(CTxMemPool::setEntries &testSet)
Remove confirmed (inBlock) entries from given set.
void resetBlock()
Clear the block's state and prepare for assembling a new block.
bool TestPackage(uint64_t packageSize, int64_t packageSigOpsCost) const
Test if a new package would "fit" in the block.
const CTxMemPool *const m_mempool
bool TestPackageTransactions(const CTxMemPool::setEntries &package) const
Perform checks on each transaction in a package: locktime, premature-witness, serialized size (if nec...
const CChainParams & chainparams
void addPackageTxs(const CTxMemPool &mempool, int &nPackagesSelected, int &nDescendantsUpdated) EXCLUSIVE_LOCKS_REQUIRED(mempool.cs)
Add transactions based on feerate including unconfirmed ancestors Increments nPackagesSelected / nDes...
std::unique_ptr< CBlockTemplate > CreateNewBlock(const CScript &scriptPubKeyIn)
Construct a new block template with coinbase to scriptPubKeyIn.
void SortForBlock(const CTxMemPool::setEntries &package, std::vector< CTxMemPool::txiter > &sortedEntries)
Sort the package in an order that is valid to appear in a block.
CTxMemPool::setEntries inBlock
uint64_t nBlockSigOpsCost
BlockAssembler(Chainstate &chainstate, const CTxMemPool *mempool)
int64_t m_lock_time_cutoff
std::unique_ptr< CBlockTemplate > pblocktemplate
static std::optional< int64_t > m_last_block_num_txs
void AddToBlock(CTxMemPool::txiter iter)
Add a tx to the block.
static std::optional< int64_t > m_last_block_weight
Transaction validation functions.
indexed_modified_transaction_set::nth_index< 0 >::type::iterator modtxiter
void RegenerateCommitments(CBlock &block, ChainstateManager &chainman)
Update an old GenerateCoinbaseCommitment from CreateNewBlock after the block txs have changed.
static const bool DEFAULT_PRINTPRIORITY
int64_t UpdateTime(CBlockHeader *pblock, const Consensus::Params &consensusParams, const CBlockIndex *pindexPrev)
indexed_modified_transaction_set::index< ancestor_score >::type::iterator modtxscoreiter
boost::multi_index_container< CTxMemPoolModifiedEntry, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< modifiedentry_iter, CompareCTxMemPoolIter >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ancestor_score >, boost::multi_index::identity< CTxMemPoolModifiedEntry >, CompareTxMemPoolEntryByAncestorFee > >> indexed_modified_transaction_set
std::optional< bilingual_str > ApplyArgsManOptions(const ArgsManager &args, BlockManager::Options &opts)
static constexpr unsigned int DEFAULT_BLOCK_MIN_TX_FEE
Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by min...
static constexpr unsigned int DEFAULT_BLOCK_MAX_WEIGHT
Default for -blockmaxweight, which controls the range of block weights the mining code will create.
Parameters that influence chain consensus.
std::vector< int64_t > vTxSigOpsCost
std::vector< CAmount > vTxFees
std::vector< unsigned char > vchCoinbaseCommitment
CAmount nModFeesWithAncestors
CAmount GetModFeesWithAncestors() const
CTxMemPoolModifiedEntry(CTxMemPool::txiter entry)
CAmount GetModifiedFee() const
uint64_t GetSizeWithAncestors() const
uint64_t nSizeWithAncestors
int64_t nSigOpCostWithAncestors
const CTransaction & GetTx() const
Comparator for CTxMemPool::txiter objects.
bool operator()(const CTxMemPool::txiter &a, const CTxMemPool::txiter &b) const
bool operator()(const CTxMemPool::txiter &a, const CTxMemPool::txiter &b) const
CTxMemPool::txiter result_type
result_type operator()(const CTxMemPoolModifiedEntry &entry) const
update_for_parent_inclusion(CTxMemPool::txiter it)
void operator()(CTxMemPoolModifiedEntry &e)
#define EXCLUSIVE_LOCKS_REQUIRED(...)