Bitcoin
Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
BlockAssembler Class Reference

#include <miner.h>

Classes

struct  Options
 

Public Member Functions

 BlockAssembler (const CChainParams &params)
 
 BlockAssembler (const CChainParams &params, const Options &options)
 
std::unique_ptr< CBlockTemplateCreateNewBlock (const CScript &scriptPubKeyIn)
 

Static Public Attributes

static Optional< int64_tm_last_block_num_txs {nullopt}
 
static Optional< int64_tm_last_block_weight {nullopt}
 

Private Member Functions

void resetBlock ()
 
void AddToBlock (CTxMemPool::txiter iter)
 
void addPackageTxs (int &nPackagesSelected, int &nDescendantsUpdated) EXCLUSIVE_LOCKS_REQUIRED(mempool.cs)
 
void onlyUnconfirmed (CTxMemPool::setEntries &testSet)
 
bool TestPackage (uint64_t packageSize, int64_t packageSigOpsCost) const
 
bool TestPackageTransactions (const CTxMemPool::setEntries &package)
 
bool SkipMapTxEntry (CTxMemPool::txiter it, indexed_modified_transaction_set &mapModifiedTx, CTxMemPool::setEntries &failedTx) EXCLUSIVE_LOCKS_REQUIRED(mempool.cs)
 
void SortForBlock (const CTxMemPool::setEntries &package, std::vector< CTxMemPool::txiter > &sortedEntries)
 
int UpdatePackagesForAdded (const CTxMemPool::setEntries &alreadyAdded, indexed_modified_transaction_set &mapModifiedTx) EXCLUSIVE_LOCKS_REQUIRED(mempool.cs)
 

Private Attributes

std::unique_ptr< CBlockTemplatepblocktemplate
 
CBlockpblock
 
bool fIncludeWitness
 
unsigned int nBlockMaxWeight
 
CFeeRate blockMinFeeRate
 
uint64_t nBlockWeight
 
uint64_t nBlockTx
 
uint64_t nBlockSigOpsCost
 
CAmount nFees
 
CTxMemPool::setEntries inBlock
 
int nHeight
 
int64_t nLockTimeCutoff
 
const CChainParamschainparams
 

Detailed Description

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

Constructor & Destructor Documentation

◆ BlockAssembler() [1/2]

BlockAssembler::BlockAssembler ( const CChainParams params)
explicit

◆ BlockAssembler() [2/2]

BlockAssembler::BlockAssembler ( const CChainParams params,
const Options options 
)

Member Function Documentation

◆ addPackageTxs()

void BlockAssembler::addPackageTxs ( int &  nPackagesSelected,
int &  nDescendantsUpdated 
)
private

Add transactions based on feerate including unconfirmed ancestors Increments nPackagesSelected / nDescendantsUpdated with corresponding statistics from the package selection (for logging statistics).

◆ AddToBlock()

void BlockAssembler::AddToBlock ( CTxMemPool::txiter  iter)
private

Add a tx to the block

◆ CreateNewBlock()

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

Construct a new block template with coinbase to scriptPubKeyIn

◆ onlyUnconfirmed()

void BlockAssembler::onlyUnconfirmed ( CTxMemPool::setEntries testSet)
private

Remove confirmed (inBlock) entries from given set

◆ resetBlock()

void BlockAssembler::resetBlock ( )
private

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

◆ SkipMapTxEntry()

bool BlockAssembler::SkipMapTxEntry ( CTxMemPool::txiter  it,
indexed_modified_transaction_set mapModifiedTx,
CTxMemPool::setEntries failedTx 
)
private

Return true if given transaction from mapTx has already been evaluated, or if the transaction's cached data in mapTx is incorrect.

◆ SortForBlock()

void BlockAssembler::SortForBlock ( const CTxMemPool::setEntries package,
std::vector< CTxMemPool::txiter > &  sortedEntries 
)
private

Sort the package in an order that is valid to appear in a block

◆ TestPackage()

bool BlockAssembler::TestPackage ( uint64_t  packageSize,
int64_t  packageSigOpsCost 
) const
private

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

◆ TestPackageTransactions()

bool BlockAssembler::TestPackageTransactions ( const CTxMemPool::setEntries package)
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

◆ UpdatePackagesForAdded()

int BlockAssembler::UpdatePackagesForAdded ( const CTxMemPool::setEntries alreadyAdded,
indexed_modified_transaction_set mapModifiedTx 
)
private

Add descendants of given transactions to mapModifiedTx with ancestor state updated assuming given transactions are inBlock. Returns number of updated descendants.

Member Data Documentation

◆ blockMinFeeRate

CFeeRate BlockAssembler::blockMinFeeRate
private

◆ chainparams

const CChainParams& BlockAssembler::chainparams
private

◆ fIncludeWitness

bool BlockAssembler::fIncludeWitness
private

◆ inBlock

CTxMemPool::setEntries BlockAssembler::inBlock
private

◆ m_last_block_num_txs

Optional< int64_t > BlockAssembler::m_last_block_num_txs {nullopt}
static

◆ m_last_block_weight

Optional< int64_t > BlockAssembler::m_last_block_weight {nullopt}
static

◆ nBlockMaxWeight

unsigned int BlockAssembler::nBlockMaxWeight
private

◆ nBlockSigOpsCost

uint64_t BlockAssembler::nBlockSigOpsCost
private

◆ nBlockTx

uint64_t BlockAssembler::nBlockTx
private

◆ nBlockWeight

uint64_t BlockAssembler::nBlockWeight
private

◆ nFees

CAmount BlockAssembler::nFees
private

◆ nHeight

int BlockAssembler::nHeight
private

◆ nLockTimeCutoff

int64_t BlockAssembler::nLockTimeCutoff
private

◆ pblock

CBlock* BlockAssembler::pblock
private

◆ pblocktemplate

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

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