Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

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

#include <miner.h>

+ Collaboration diagram for BlockAssembler:

Classes

struct  Options
 

Public Member Functions

 BlockAssembler (const CChainParams &params)
 
 BlockAssembler (const CChainParams &params, const Options &options)
 
std::unique_ptr< CBlockTemplateCreateNewBlock (const CScript &scriptPubKeyIn)
 Construct a new block template with coinbase to scriptPubKeyIn. More...
 

Private Member Functions

void resetBlock ()
 Clear the block's state and prepare for assembling a new block. More...
 
void AddToBlock (CTxMemPool::txiter iter)
 Add a tx to the block. More...
 
void addPackageTxs (int &nPackagesSelected, int &nDescendantsUpdated)
 Add transactions based on feerate including unconfirmed ancestors Increments nPackagesSelected / nDescendantsUpdated with corresponding statistics from the package selection (for logging statistics). More...
 
void onlyUnconfirmed (CTxMemPool::setEntries &testSet)
 Remove confirmed (inBlock) entries from given set. More...
 
bool TestPackage (uint64_t packageSize, unsigned int packageSigOps) const
 Test if a new package would "fit" in the block. More...
 
bool TestPackageTransactions (const CTxMemPool::setEntries &package)
 Perform checks on each transaction in a package: locktime These checks should always succeed, and they're here only as an extra check in case of suboptimal node configuration. More...
 
bool SkipMapTxEntry (CTxMemPool::txiter it, indexed_modified_transaction_set &mapModifiedTx, CTxMemPool::setEntries &failedTx)
 Return true if given transaction from mapTx has already been evaluated, or if the transaction's cached data in mapTx is incorrect. More...
 
void SortForBlock (const CTxMemPool::setEntries &package, CTxMemPool::txiter entry, std::vector< CTxMemPool::txiter > &sortedEntries)
 Sort the package in an order that is valid to appear in a block. More...
 
int UpdatePackagesForAdded (const CTxMemPool::setEntries &alreadyAdded, indexed_modified_transaction_set &mapModifiedTx)
 Add descendants of given transactions to mapModifiedTx with ancestor state updated assuming given transactions are inBlock. More...
 

Private Attributes

std::unique_ptr< CBlockTemplatepblocktemplate
 
CBlockpblock
 
unsigned int nBlockMaxSize
 
CFeeRate blockMinFeeRate
 
uint64_t nBlockSize
 
uint64_t nBlockTx
 
unsigned int nBlockSigOps
 
CAmount nFees
 
CTxMemPool::setEntries inBlock
 
int nHeight
 
int64_t nLockTimeCutoff
 
const CChainParamschainparams
 

Detailed Description

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

Definition at line 126 of file miner.h.

Constructor & Destructor Documentation

◆ BlockAssembler() [1/2]

BlockAssembler::BlockAssembler ( const CChainParams params)
explicit

Definition at line 104 of file miner.cpp.

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

Definition at line 370 of file miner.cpp.

References AddToBlock(), blockMinFeeRate, CTxMemPool::CalculateMemPoolAncestors(), CFeeRate::GetFee(), inBlock, CTxMemPool::mapTx, mempool, nBlockMaxSize, nBlockSize, onlyUnconfirmed(), SkipMapTxEntry(), SortForBlock(), TestPackage(), TestPackageTransactions(), and UpdatePackagesForAdded().

Referenced by CreateNewBlock().

◆ AddToBlock()

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

◆ CreateNewBlock()

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

Construct a new block template with coinbase to scriptPubKeyIn.

Definition at line 119 of file miner.cpp.

References addPackageTxs(), BCLog::BENCHMARK, CChainParams::BIP9CheckMasternodesUpgraded(), CalcCbTxMerkleRootMNList(), CalcCbTxMerkleRootQuorums(), chainActive, chainparams, ComputeBlockVersion(), CTxMemPool::cs, cs_main, Consensus::DEPLOYMENT_DIP0008, Consensus::Params::DIP0003Height, FillBlockPayments(), FormatStateMessage(), gArgs, GetAdjustedTime(), ArgsManager::GetArg(), CBlockIndex::GetBlockHash(), GetBlockSubsidy(), CBlockHeader::GetBlockTime(), CChainParams::GetConsensus(), GetLegacySigOpCount(), CBlockIndex::GetMedianTimePast(), GetNextWorkRequired(), GetTimeMicros(), CBlockHeader::hashPrevBlock, Consensus::Params::llmqs, LOCK2, LOCKTIME_MEDIAN_TIME_PAST, LogPrint, LogPrintf, MakeTransactionRef(), mempool, CCbTx::merkleRootMNList, CCbTx::merkleRootQuorums, CChainParams::MineBlocksOnDemand(), CBlockHeader::nBits, CBlockIndex::nBits, nBlockSigOps, nBlockSize, nBlockTx, nFees, CCbTx::nHeight, nHeight, CBlockIndex::nHeight, nLastBlockSize, nLastBlockTx, nLockTimeCutoff, CBlockHeader::nNonce, CBlockHeader::nTime, CMutableTransaction::nType, CCbTx::nVersion, CBlockHeader::nVersion, CMutableTransaction::nVersion, OP_0, OP_RETURN, Params(), pblock, pblocktemplate, llmq::quorumBlockProcessor, resetBlock(), SetTxPayload(), STANDARD_LOCKTIME_VERIFY_FLAGS, strprintf, TestBlockValidity(), THRESHOLD_ACTIVE, CChain::Tip(), TRANSACTION_COINBASE, UpdateTime(), versionbitscache, VersionBitsState(), CMutableTransaction::vin, CMutableTransaction::vout, and CBlock::vtx.

Referenced by getblocktemplate().

◆ onlyUnconfirmed()

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

Remove confirmed (inBlock) entries from given set.

Definition at line 251 of file miner.cpp.

References inBlock.

Referenced by addPackageTxs().

◆ resetBlock()

void BlockAssembler::resetBlock ( )
private

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

Definition at line 106 of file miner.cpp.

References inBlock, nBlockSigOps, nBlockSize, nBlockTx, and nFees.

Referenced by CreateNewBlock().

◆ 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.

Definition at line 343 of file miner.cpp.

References inBlock, CTxMemPool::mapTx, and mempool.

Referenced by addPackageTxs().

◆ SortForBlock()

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

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

Definition at line 349 of file miner.cpp.

Referenced by addPackageTxs().

◆ TestPackage()

bool BlockAssembler::TestPackage ( uint64_t  packageSize,
unsigned int  packageSigOps 
) const
private

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

Definition at line 264 of file miner.cpp.

References fDIP0001ActiveAtTip, MaxBlockSigOps(), nBlockMaxSize, nBlockSigOps, and nBlockSize.

Referenced by addPackageTxs().

◆ TestPackageTransactions()

bool BlockAssembler::TestPackageTransactions ( const CTxMemPool::setEntries package)
private

Perform checks on each transaction in a package: locktime These checks should always succeed, and they're here only as an extra check in case of suboptimal node configuration.

Definition at line 276 of file miner.cpp.

References llmq::chainLocksHandler, IsFinalTx(), nHeight, and nLockTimeCutoff.

Referenced by addPackageTxs().

◆ 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.

Definition at line 307 of file miner.cpp.

References CTxMemPool::CalculateDescendants(), mempool, CTxMemPoolModifiedEntry::nModFeesWithAncestors, CTxMemPoolModifiedEntry::nSigOpCountWithAncestors, and CTxMemPoolModifiedEntry::nSizeWithAncestors.

Referenced by addPackageTxs().

Member Data Documentation

◆ blockMinFeeRate

CFeeRate BlockAssembler::blockMinFeeRate
private

Definition at line 136 of file miner.h.

Referenced by addPackageTxs(), and BlockAssembler().

◆ chainparams

const CChainParams& BlockAssembler::chainparams
private

Definition at line 148 of file miner.h.

Referenced by CreateNewBlock().

◆ inBlock

CTxMemPool::setEntries BlockAssembler::inBlock
private

Definition at line 143 of file miner.h.

Referenced by addPackageTxs(), AddToBlock(), onlyUnconfirmed(), resetBlock(), and SkipMapTxEntry().

◆ nBlockMaxSize

unsigned int BlockAssembler::nBlockMaxSize
private

Definition at line 135 of file miner.h.

Referenced by addPackageTxs(), BlockAssembler(), and TestPackage().

◆ nBlockSigOps

unsigned int BlockAssembler::nBlockSigOps
private

Definition at line 141 of file miner.h.

Referenced by AddToBlock(), CreateNewBlock(), resetBlock(), and TestPackage().

◆ nBlockSize

uint64_t BlockAssembler::nBlockSize
private

Definition at line 139 of file miner.h.

Referenced by addPackageTxs(), AddToBlock(), CreateNewBlock(), resetBlock(), and TestPackage().

◆ nBlockTx

uint64_t BlockAssembler::nBlockTx
private

Definition at line 140 of file miner.h.

Referenced by AddToBlock(), CreateNewBlock(), and resetBlock().

◆ nFees

CAmount BlockAssembler::nFees
private

Definition at line 142 of file miner.h.

Referenced by AddToBlock(), CreateNewBlock(), and resetBlock().

◆ nHeight

int BlockAssembler::nHeight
private

Definition at line 146 of file miner.h.

Referenced by CreateNewBlock(), and TestPackageTransactions().

◆ nLockTimeCutoff

int64_t BlockAssembler::nLockTimeCutoff
private

Definition at line 147 of file miner.h.

Referenced by CreateNewBlock(), and TestPackageTransactions().

◆ pblock

CBlock* BlockAssembler::pblock
private

Definition at line 132 of file miner.h.

Referenced by AddToBlock(), and CreateNewBlock().

◆ pblocktemplate

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

Definition at line 130 of file miner.h.

Referenced by AddToBlock(), and CreateNewBlock().


The documentation for this class was generated from the following files:
Released under the MIT license