6 #ifndef BITCOIN_NODE_MINER_H 7 #define BITCOIN_NODE_MINER_H 13 #include <txmempool.h> 20 #include <boost/multi_index/identity.hpp> 21 #include <boost/multi_index/indexed_by.hpp> 22 #include <boost/multi_index/ordered_index.hpp> 23 #include <boost/multi_index/tag.hpp> 24 #include <boost/multi_index_container.hpp> 38 class KernelNotifications;
156 bool& interrupt_wait);
189 #endif // BITCOIN_NODE_MINER_H std::shared_ptr< const CTransaction > CTransactionRef
static const bool DEFAULT_PRINT_MODIFIED_FEE
Generate a new block, without valid proof-of-work.
void resetBlock()
Clear the block's state and prepare for assembling a new block.
Interface for managing multiple Chainstate objects, where each chainstate is associated with chainsta...
bool TestChunkBlockLimits(FeePerWeight chunk_feerate, int64_t chunk_sigops_cost) const
Test if a new chunk would "fit" in the block.
std::optional< BlockRef > GetTip(ChainstateManager &chainman)
bool TestChunkTransactions(const std::vector< CTxMemPoolEntryRef > &txs) const
Perform locktime checks on each transaction in a chunk: This check should always succeed, and is here only as an extra check in case of a bug.
static std::optional< int64_t > m_last_block_num_txs
The number of transactions in the last assembled block (excluding coinbase transaction) ...
Hash/height pair to help track and identify blocks.
std::optional< BlockRef > WaitTipChanged(ChainstateManager &chainman, KernelNotifications &kernel_notifications, const uint256 ¤t_tip, MillisecondsDouble &timeout, bool &interrupt)
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system...
util::Result< void > ApplyArgsManOptions(const ArgsManager &args, BlockManager::Options &opts)
Tagged wrapper around FeeFrac to avoid unit confusion.
CTxMemPoolEntry::CTxMemPoolEntryRef CTxMemPoolEntryRef
int64_t UpdateTime(CBlockHeader *pblock, const Consensus::Params &consensusParams, const CBlockIndex *pindexPrev)
int64_t m_lock_time_cutoff
std::unique_ptr< CBlockTemplate > CreateNewBlock()
Construct a new block template.
Transaction validation functions.
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
int64_t CAmount
Amount in satoshis (Can be negative)
std::vector< int64_t > vTxSigOpsCost
Chainstate stores and provides an API to update our local knowledge of the current best chain...
void AddMerkleRootAndCoinbase(CBlock &block, CTransactionRef coinbase, uint32_t version, uint32_t timestamp, uint32_t nonce)
Template containing all coinbase transaction fields that are set by our miner code.
void InterruptWait(KernelNotifications &kernel_notifications, bool &interrupt_wait)
Chainstate & m_chainstate
int64_t GetMinimumTime(const CBlockIndex *pindexPrev, const int64_t difficulty_adjustment_interval)
Get the minimum time a miner should use in the next block.
static std::optional< int64_t > m_last_block_weight
The weight of the last assembled block (including reserved weight for block header, txs count and coinbase tx)
void addChunks() EXCLUSIVE_LOCKS_REQUIRED(m_mempool -> cs)
Add transactions based on chunk feerate.
#define EXCLUSIVE_LOCKS_REQUIRED(...)
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
std::vector< FeePerVSize > m_package_feerates
The block chain is a tree shaped structure starting with the genesis block at the root...
const CChainParams & Params()
Return the currently selected parameters.
Serialized script, used inside transaction inputs and outputs.
BlockAssembler(Chainstate &chainstate, const CTxMemPool *mempool, const Options &options)
const CChainParams & chainparams
static constexpr unsigned int DEFAULT_BLOCK_MAX_WEIGHT
Default for -blockmaxweight, which controls the range of block weights the mining code will create...
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac...
bool CooldownIfHeadersAhead(ChainstateManager &chainman, KernelNotifications &kernel_notifications, const BlockRef &last_tip, bool &interrupt_mining)
Wait while the best known header extends the current chain tip AND at least one block is being added ...
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...
uint64_t nBlockSigOpsCost
std::vector< CAmount > vTxFees
std::unique_ptr< CBlockTemplate > pblocktemplate
is a home for public enum and struct type definitions that are used internally by node code...
std::unique_ptr< CBlockTemplate > WaitAndCreateNewBlock(ChainstateManager &chainman, KernelNotifications &kernel_notifications, CTxMemPool *mempool, const std::unique_ptr< CBlockTemplate > &block_template, const BlockWaitOptions &options, const BlockAssembler::Options &assemble_options, bool &interrupt_wait)
Return a new block template when fees rise to a certain threshold or after a new tip; return nullopt ...
void AddToBlock(const CTxMemPoolEntry &entry)
Add a tx to the block.
void RegenerateCommitments(CBlock &block, ChainstateManager &chainman)
Update an old GenerateCoinbaseCommitment from CreateNewBlock after the block txs have changed...
std::chrono::duration< double, std::chrono::milliseconds::period > MillisecondsDouble
const CTxMemPool *const m_mempool