Raven Core  3.0.0
P2P Digital Currency
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
BlockAssembler Class Reference

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

#include <miner.h>

Collaboration diagram for BlockAssembler:
[legend]

Classes

struct  Options
 

Public Member Functions

 BlockAssembler (const CChainParams &params)
 
 BlockAssembler (const CChainParams &params, const Options &options)
 
std::unique_ptr< CBlockTemplateCreateNewBlock (const CScript &scriptPubKeyIn, bool fMineWitnessTx=true)
 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, int64_t packageSigOpsCost) 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, 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...
 
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
 
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.

Definition at line 133 of file miner.h.

Constructor & Destructor Documentation

◆ BlockAssembler() [1/2]

BlockAssembler::BlockAssembler ( const CChainParams params)
explicit

Definition at line 105 of file miner.cpp.

◆ BlockAssembler() [2/2]

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

Definition at line 80 of file miner.cpp.

Here is the call graph for this function:

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 325 of file miner.cpp.

Here is the call graph for this function:

◆ AddToBlock()

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

Add a tx to the block.

Definition at line 243 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 > BlockAssembler::CreateNewBlock ( const CScript scriptPubKeyIn,
bool  fMineWitnessTx = true 
)

Construct a new block template with coinbase to scriptPubKeyIn.

Definition at line 121 of file miner.cpp.

Here is the call graph for this function:

◆ onlyUnconfirmed()

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

Remove confirmed (inBlock) entries from given set.

Definition at line 205 of file miner.cpp.

Here is the caller graph for this function:

◆ resetBlock()

void BlockAssembler::resetBlock ( )
private

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

Definition at line 107 of file miner.cpp.

Here is the caller graph for this function:

◆ 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 298 of file miner.cpp.

Here is the caller graph for this function:

◆ 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 304 of file miner.cpp.

Here is the caller graph for this function:

◆ TestPackage()

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

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

Definition at line 218 of file miner.cpp.

Here is the caller graph for this function:

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

Definition at line 232 of file miner.cpp.

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

◆ 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 262 of file miner.cpp.

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

Member Data Documentation

◆ blockMinFeeRate

CFeeRate BlockAssembler::blockMinFeeRate
private

Definition at line 144 of file miner.h.

◆ chainparams

const CChainParams& BlockAssembler::chainparams
private

Definition at line 156 of file miner.h.

◆ fIncludeWitness

bool BlockAssembler::fIncludeWitness
private

Definition at line 142 of file miner.h.

◆ inBlock

CTxMemPool::setEntries BlockAssembler::inBlock
private

Definition at line 151 of file miner.h.

◆ nBlockMaxWeight

unsigned int BlockAssembler::nBlockMaxWeight
private

Definition at line 143 of file miner.h.

◆ nBlockSigOpsCost

uint64_t BlockAssembler::nBlockSigOpsCost
private

Definition at line 149 of file miner.h.

◆ nBlockTx

uint64_t BlockAssembler::nBlockTx
private

Definition at line 148 of file miner.h.

◆ nBlockWeight

uint64_t BlockAssembler::nBlockWeight
private

Definition at line 147 of file miner.h.

◆ nFees

CAmount BlockAssembler::nFees
private

Definition at line 150 of file miner.h.

◆ nHeight

int BlockAssembler::nHeight
private

Definition at line 154 of file miner.h.

◆ nLockTimeCutoff

int64_t BlockAssembler::nLockTimeCutoff
private

Definition at line 155 of file miner.h.

◆ pblock

CBlock* BlockAssembler::pblock
private

Definition at line 139 of file miner.h.

◆ pblocktemplate

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

Definition at line 137 of file miner.h.


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