Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
BlockAssembler Class Reference

Generate a new block, without valid proof-of-work. More...

#include <miner.h>

Collaboration diagram for BlockAssembler:
[legend]

Classes

struct  Options

Public Member Functions

 BlockAssembler (Chainstate &chainstate, const CTxMemPool *mempool, const Options &options)
std::unique_ptr< CBlockTemplateCreateNewBlock ()
 Construct a new block template.

Static Public Attributes

static std::optional< int64_t > m_last_block_num_txs {}
 The number of transactions in the last assembled block (excluding coinbase transaction).
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).

Private Member Functions

void resetBlock ()
 Clear the block's state and prepare for assembling a new block.
void AddToBlock (const CTxMemPoolEntry &entry)
 Add a tx to the block.
void addChunks () EXCLUSIVE_LOCKS_REQUIRED(m_mempool -> cs)
 Add transactions based on chunk feerate.
bool TestChunkBlockLimits (FeePerWeight chunk_feerate, int64_t chunk_sigops_cost) const
 Test if a new chunk would "fit" in the block.
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.

Private Attributes

std::unique_ptr< CBlockTemplatepblocktemplate
uint64_t nBlockWeight
uint64_t nBlockTx
uint64_t nBlockSigOpsCost
CAmount nFees
int nHeight
int64_t m_lock_time_cutoff
const CChainParamschainparams
const CTxMemPool *const m_mempool
Chainstatem_chainstate
const Options m_options

Detailed Description

Generate a new block, without valid proof-of-work.

Definition at line 60 of file miner.h.

Constructor & Destructor Documentation

◆ BlockAssembler()

node::BlockAssembler::BlockAssembler ( Chainstate & chainstate,
const CTxMemPool * mempool,
const Options & options )
explicit

Definition at line 90 of file miner.cpp.

Member Function Documentation

◆ addChunks()

void node::BlockAssembler::addChunks ( ) -> cs)
private

Add transactions based on chunk feerate.

Precondition
BlockAssembler::m_mempool must not be nullptr

Definition at line 279 of file miner.cpp.

Here is the caller graph for this function:

◆ AddToBlock()

void node::BlockAssembler::AddToBlock ( const CTxMemPoolEntry & entry)
private

Add a tx to the block.

Definition at line 262 of file miner.cpp.

Here is the caller graph for this function:

◆ CreateNewBlock()

Construct a new block template.

Definition at line 122 of file miner.cpp.

◆ resetBlock()

Clear the block's state and prepare for assembling a new block.

Definition at line 111 of file miner.cpp.

Here is the caller graph for this function:

◆ TestChunkBlockLimits()

bool node::BlockAssembler::TestChunkBlockLimits ( FeePerWeight chunk_feerate,
int64_t chunk_sigops_cost ) const
private

Test if a new chunk would "fit" in the block.

Definition at line 239 of file miner.cpp.

Here is the caller graph for this function:

◆ TestChunkTransactions()

bool node::BlockAssembler::TestChunkTransactions ( const std::vector< CTxMemPoolEntryRef > & txs) const
private

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.

Definition at line 252 of file miner.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ chainparams

Definition at line 76 of file miner.h.

◆ m_chainstate

Definition at line 78 of file miner.h.

◆ m_last_block_num_txs

std::optional<int64_t> node::BlockAssembler::m_last_block_num_txs {}
inlinestatic

The number of transactions in the last assembled block (excluding coinbase transaction).

Definition at line 96 of file miner.h.

◆ m_last_block_weight

std::optional<int64_t> node::BlockAssembler::m_last_block_weight {}
inlinestatic

The weight of the last assembled block (including reserved weight for block header, txs count and coinbase tx).

Definition at line 98 of file miner.h.

◆ m_lock_time_cutoff

Definition at line 74 of file miner.h.

◆ m_mempool

Definition at line 77 of file miner.h.

◆ m_options

Definition at line 101 of file miner.h.

◆ nBlockSigOpsCost

Definition at line 69 of file miner.h.

◆ nBlockTx

Definition at line 68 of file miner.h.

◆ nBlockWeight

Definition at line 67 of file miner.h.

◆ nFees

Definition at line 70 of file miner.h.

◆ nHeight

Definition at line 73 of file miner.h.

◆ pblocktemplate

Definition at line 64 of file miner.h.


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