Bitcoin ABC 0.32.4
P2P Digital Currency
Classes | Public Member Functions | Public Attributes | 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 (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)
 
 BlockAssembler (const node::BlockFitter &fitter, Chainstate &chainstate, const CTxMemPool *mempool, const Options &options, 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
 
void addTxs (const CTxMemPool &mempool) EXCLUSIVE_LOCKS_REQUIRED(mempool.cs)
 Add transactions from the mempool based on individual tx feerate. More...
 
void addFinalizedTxs (const CTxMemPool &mempool) EXCLUSIVE_LOCKS_REQUIRED(mempool.cs)
 Add the finalized transactions to the block template. More...
 

Public Attributes

std::unique_ptr< CBlockTemplatepblocktemplate
 

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...
 
bool CheckTx (const CTransaction &tx) const
 Check the transaction for finality, etc before adding to block. More...
 

Private Attributes

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
 
const bool test_block_validity
 
const bool add_finalized_txs
 

Detailed Description

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

Definition at line 55 of file miner.h.

Constructor & Destructor Documentation

◆ BlockAssembler() [1/3]

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

Definition at line 88 of file miner.cpp.

◆ BlockAssembler() [2/3]

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

Definition at line 81 of file miner.cpp.

◆ BlockAssembler() [3/3]

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

Definition at line 70 of file miner.cpp.

Member Function Documentation

◆ addFinalizedTxs()

void node::BlockAssembler::addFinalizedTxs ( const CTxMemPool mempool)

Add the finalized transactions to the block template.

addFinalizedTxs fills the template with the finalized transactons.

The radix tree is making sure it's all ready to go and already sorted so there is no check to do anymore.

Definition at line 399 of file miner.cpp.

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

◆ AddToBlock()

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

Add a tx to the block.

Definition at line 245 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)

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 271 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 260 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 97 of file miner.cpp.

Here is the call graph for this function:

◆ GetMaxGeneratedBlockSize()

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

Definition at line 96 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

◆ add_finalized_txs

const bool node::BlockAssembler::add_finalized_txs
private

Definition at line 73 of file miner.h.

◆ blockFitter

BlockFitter node::BlockAssembler::blockFitter
private

Definition at line 57 of file miner.h.

◆ chainParams

const CChainParams& node::BlockAssembler::chainParams
private

Definition at line 62 of file miner.h.

◆ fPrintPriority

const bool node::BlockAssembler::fPrintPriority
private

Definition at line 68 of file miner.h.

◆ m_avalanche

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

Definition at line 66 of file miner.h.

◆ m_chainstate

Chainstate& node::BlockAssembler::m_chainstate
private

Definition at line 65 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 114 of file miner.h.

◆ m_last_block_size

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

Definition at line 115 of file miner.h.

◆ m_lock_time_cutoff

int64_t node::BlockAssembler::m_lock_time_cutoff
private

Definition at line 61 of file miner.h.

◆ m_mempool

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

Definition at line 64 of file miner.h.

◆ nHeight

int node::BlockAssembler::nHeight
private

Definition at line 60 of file miner.h.

◆ pblocktemplate

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

Definition at line 112 of file miner.h.

◆ test_block_validity

const bool node::BlockAssembler::test_block_validity
private

Definition at line 71 of file miner.h.


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