Bitcoin Core 30.99.0
P2P Digital Currency
Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
node::BlockAssembler Class Reference

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

#include <miner.h>

Collaboration diagram for node::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. More...
 

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) More...
 
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) More...
 

Private Member Functions

void resetBlock ()
 Clear the block's state and prepare for assembling a new block. More...
 
void AddToBlock (const CTxMemPoolEntry &entry)
 Add a tx to the block. More...
 
void addChunks () EXCLUSIVE_LOCKS_REQUIRED(m_mempool -> cs)
 Add transactions based on chunk feerate. More...
 
bool TestPackage (FeePerWeight package_feerate, int64_t packageSigOpsCost) const
 Test if a new package would "fit" in the block. More...
 
bool TestPackageTransactions (const std::vector< CTxMemPoolEntryRef > &txs) const
 Perform checks on each transaction in a package: locktime, premature-witness, serialized size (if necessary) These checks should always succeed, and they're here only as an extra check in case of suboptimal node configuration. More...
 

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 56 of file miner.h.

Constructor & Destructor Documentation

◆ BlockAssembler()

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

Definition at line 89 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 236 of file miner.cpp.

Here is the call graph for this function:

◆ AddToBlock()

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

Add a tx to the block.

Definition at line 219 of file miner.cpp.

Here is the call graph for this function:

◆ CreateNewBlock()

std::unique_ptr< CBlockTemplate > node::BlockAssembler::CreateNewBlock ( )

Construct a new block template.

Definition at line 119 of file miner.cpp.

Here is the call graph for this function:

◆ resetBlock()

void node::BlockAssembler::resetBlock ( )
private

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

Definition at line 108 of file miner.cpp.

◆ TestPackage()

bool node::BlockAssembler::TestPackage ( FeePerWeight  package_feerate,
int64_t  packageSigOpsCost 
) const
private

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

Definition at line 196 of file miner.cpp.

◆ TestPackageTransactions()

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

Perform checks on each transaction in a package: locktime, premature-witness, serialized size (if necessary) These checks should always succeed, and they're here only as an extra check in case of suboptimal node configuration.

Definition at line 209 of file miner.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ chainparams

const CChainParams& node::BlockAssembler::chainparams
private

Definition at line 72 of file miner.h.

◆ m_chainstate

Chainstate& node::BlockAssembler::m_chainstate
private

Definition at line 74 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 92 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 94 of file miner.h.

◆ m_lock_time_cutoff

int64_t node::BlockAssembler::m_lock_time_cutoff
private

Definition at line 70 of file miner.h.

◆ m_mempool

const CTxMemPool* const node::BlockAssembler::m_mempool
private

Definition at line 73 of file miner.h.

◆ m_options

const Options node::BlockAssembler::m_options
private

Definition at line 97 of file miner.h.

◆ nBlockSigOpsCost

uint64_t node::BlockAssembler::nBlockSigOpsCost
private

Definition at line 65 of file miner.h.

◆ nBlockTx

uint64_t node::BlockAssembler::nBlockTx
private

Definition at line 64 of file miner.h.

◆ nBlockWeight

uint64_t node::BlockAssembler::nBlockWeight
private

Definition at line 63 of file miner.h.

◆ nFees

CAmount node::BlockAssembler::nFees
private

Definition at line 66 of file miner.h.

◆ nHeight

int node::BlockAssembler::nHeight
private

Definition at line 69 of file miner.h.

◆ pblocktemplate

std::unique_ptr<CBlockTemplate> node::BlockAssembler::pblocktemplate
private

Definition at line 60 of file miner.h.


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