Bitcoin ABC 0.31.1
P2P Digital Currency
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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]

Public Member Functions

 BlockAssembler (const Config &config, Chainstate &chainstate, const CTxMemPool *mempool, const avalanche::Processor *avalanche=nullptr)
 
 BlockAssembler (const node::BlockFitter &fitter, Chainstate &chainstate, const CTxMemPool *mempool, const avalanche::Processor *avalanche=nullptr)
 
std::unique_ptr< CBlockTemplateCreateNewBlock (const CScript &scriptPubKeyIn)
 Construct a new block template with coinbase to scriptPubKeyIn. More...
 
uint64_t GetMaxGeneratedBlockSize () const
 

Static Public Attributes

static std::optional< int64_t > m_last_block_num_txs {std::nullopt}
 
static std::optional< int64_t > m_last_block_size {std::nullopt}
 

Private Member Functions

void resetBlock ()
 Clear the block's state and prepare for assembling a new block. More...
 
void AddToBlock (const CTxMemPoolEntryRef &entry)
 Add a tx to the block. More...
 
void addTxs (const CTxMemPool &mempool) EXCLUSIVE_LOCKS_REQUIRED(mempool.cs)
 Add transactions from the mempool based on individual tx feerate. More...
 
bool CheckTx (const CTransaction &tx) const
 Check the transaction for finality, etc before adding to block. More...
 

Private Attributes

std::unique_ptr< CBlockTemplatepblocktemplate
 
BlockFitter blockFitter
 
int nHeight
 
int64_t m_lock_time_cutoff
 
const CChainParamschainParams
 
const CTxMemPool *const m_mempool
 
Chainstatem_chainstate
 
const avalanche::Processor *const m_avalanche
 
const bool fPrintPriority
 

Detailed Description

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

Definition at line 54 of file miner.h.

Constructor & Destructor Documentation

◆ BlockAssembler() [1/2]

node::BlockAssembler::BlockAssembler ( const Config config,
Chainstate chainstate,
const CTxMemPool mempool,
const avalanche::Processor avalanche = nullptr 
)

Definition at line 65 of file miner.cpp.

◆ BlockAssembler() [2/2]

node::BlockAssembler::BlockAssembler ( const node::BlockFitter fitter,
Chainstate chainstate,
const CTxMemPool mempool,
const avalanche::Processor avalanche = nullptr 
)

Definition at line 56 of file miner.cpp.

Member Function Documentation

◆ AddToBlock()

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

Add a tx to the block.

Definition at line 210 of file miner.cpp.

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

◆ addTxs()

void node::BlockAssembler::addTxs ( const CTxMemPool mempool)
private

Add transactions from the mempool based on individual tx feerate.

addTxs includes transactions paying a fee by ensuring that the partial ordering of transactions is maintained.

That is to say children come after parents, despite having a potentially larger fee.

Definition at line 236 of file miner.cpp.

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

◆ CheckTx()

bool node::BlockAssembler::CheckTx ( const CTransaction tx) const
private

Check the transaction for finality, etc before adding to block.

Definition at line 225 of file miner.cpp.

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

◆ CreateNewBlock()

std::unique_ptr< CBlockTemplate > node::BlockAssembler::CreateNewBlock ( const CScript scriptPubKeyIn)

Construct a new block template with coinbase to scriptPubKeyIn.

Definition at line 74 of file miner.cpp.

Here is the call graph for this function:

◆ GetMaxGeneratedBlockSize()

uint64_t node::BlockAssembler::GetMaxGeneratedBlockSize ( ) const
inline

Definition at line 84 of file miner.h.

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.

Member Data Documentation

◆ blockFitter

BlockFitter node::BlockAssembler::blockFitter
private

Definition at line 59 of file miner.h.

◆ chainParams

const CChainParams& node::BlockAssembler::chainParams
private

Definition at line 64 of file miner.h.

◆ fPrintPriority

const bool node::BlockAssembler::fPrintPriority
private

Definition at line 70 of file miner.h.

◆ m_avalanche

const avalanche::Processor* const node::BlockAssembler::m_avalanche
private

Definition at line 68 of file miner.h.

◆ m_chainstate

Chainstate& node::BlockAssembler::m_chainstate
private

Definition at line 67 of file miner.h.

◆ m_last_block_num_txs

std::optional< int64_t > node::BlockAssembler::m_last_block_num_txs {std::nullopt}
static

Definition at line 88 of file miner.h.

◆ m_last_block_size

std::optional< int64_t > node::BlockAssembler::m_last_block_size {std::nullopt}
static

Definition at line 89 of file miner.h.

◆ m_lock_time_cutoff

int64_t node::BlockAssembler::m_lock_time_cutoff
private

Definition at line 63 of file miner.h.

◆ m_mempool

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

Definition at line 66 of file miner.h.

◆ nHeight

int node::BlockAssembler::nHeight
private

Definition at line 62 of file miner.h.

◆ pblocktemplate

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

Definition at line 57 of file miner.h.


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