PIVX Core  5.6.99
P2P Digital Currency
Public Member Functions | Private Member Functions | Private Attributes | List of all members
BlockAssembler Class Reference

Generate a new block. More...

#include <blockassembler.h>

Collaboration diagram for BlockAssembler:
[legend]

Public Member Functions

 BlockAssembler (const CChainParams &chainparams, const bool defaultPrintPriority)
 
std::unique_ptr< CBlockTemplateCreateNewBlock (const CScript &scriptPubKeyIn, CWallet *pwallet=nullptr, bool fProofOfStake=false, std::vector< CStakeableOutput > *availableCoins=nullptr, bool fNoMempoolTx=false, bool fTestValidity=true, CBlockIndex *prevBlock=nullptr, bool stopPoSOnNewBlock=true, bool fIncludeQfc=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 ()
 Add transactions based on feerate including unconfirmed ancestors. More...
 
void appendSaplingTreeRoot ()
 Add the tip updated incremental merkle tree to the header. More...
 
void onlyUnconfirmed (CTxMemPool::setEntries &testSet)
 Remove confirmed (inBlock) entries from given set. More...
 
bool TestPackage (uint64_t packageSize, unsigned int packageSigOps)
 Test if a new package would "fit" in the block. More...
 
bool TestPackageFinality (const CTxMemPool::setEntries &package)
 Test if a set of transactions are all final. 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...
 
void 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 {nullptr}
 
unsigned int nBlockMaxSize {0}
 
uint64_t nBlockSize {0}
 
uint64_t nBlockTx {0}
 
unsigned int nBlockSigOps {0}
 
CAmount nFees {0}
 
CTxMemPool::setEntries inBlock
 
int nHeight {0}
 
const CChainParamschainparams
 
unsigned int nSizeShielded {0}
 
const bool defaultPrintPriority {false}
 

Detailed Description

Generate a new block.

Definition at line 134 of file blockassembler.h.

Constructor & Destructor Documentation

◆ BlockAssembler()

BlockAssembler::BlockAssembler ( const CChainParams chainparams,
const bool  defaultPrintPriority 
)

Definition at line 136 of file blockassembler.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ addPackageTxs()

void BlockAssembler::addPackageTxs ( )
private

Add transactions based on feerate including unconfirmed ancestors.

Definition at line 376 of file blockassembler.cpp.

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

◆ AddToBlock()

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

Add a tx to the block.

Definition at line 295 of file blockassembler.cpp.

Here is the call graph for this function:

◆ appendSaplingTreeRoot()

void BlockAssembler::appendSaplingTreeRoot ( )
private

Add the tip updated incremental merkle tree to the header.

Definition at line 499 of file blockassembler.cpp.

Here is the call graph for this function:

◆ CreateNewBlock()

std::unique_ptr< CBlockTemplate > BlockAssembler::CreateNewBlock ( const CScript scriptPubKeyIn,
CWallet pwallet = nullptr,
bool  fProofOfStake = false,
std::vector< CStakeableOutput > *  availableCoins = nullptr,
bool  fNoMempoolTx = false,
bool  fTestValidity = true,
CBlockIndex prevBlock = nullptr,
bool  stopPoSOnNewBlock = true,
bool  fIncludeQfc = true 
)

Construct a new block template with coinbase to scriptPubKeyIn.

Definition at line 158 of file blockassembler.cpp.

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

◆ onlyUnconfirmed()

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

Remove confirmed (inBlock) entries from given set.

Definition at line 262 of file blockassembler.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 145 of file blockassembler.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 347 of file blockassembler.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 355 of file blockassembler.cpp.

Here is the caller graph for this function:

◆ TestPackage()

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

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

Definition at line 275 of file blockassembler.cpp.

Here is the caller graph for this function:

◆ TestPackageFinality()

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

Test if a set of transactions are all final.

Definition at line 286 of file blockassembler.cpp.

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

◆ UpdatePackagesForAdded()

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

Definition at line 314 of file blockassembler.cpp.

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

Member Data Documentation

◆ chainparams

const CChainParams& BlockAssembler::chainparams
private

Definition at line 154 of file blockassembler.h.

◆ defaultPrintPriority

const bool BlockAssembler::defaultPrintPriority {false}
private

Definition at line 160 of file blockassembler.h.

◆ inBlock

CTxMemPool::setEntries BlockAssembler::inBlock
private

Definition at line 150 of file blockassembler.h.

◆ nBlockMaxSize

unsigned int BlockAssembler::nBlockMaxSize {0}
private

Definition at line 143 of file blockassembler.h.

◆ nBlockSigOps

unsigned int BlockAssembler::nBlockSigOps {0}
private

Definition at line 148 of file blockassembler.h.

◆ nBlockSize

uint64_t BlockAssembler::nBlockSize {0}
private

Definition at line 146 of file blockassembler.h.

◆ nBlockTx

uint64_t BlockAssembler::nBlockTx {0}
private

Definition at line 147 of file blockassembler.h.

◆ nFees

CAmount BlockAssembler::nFees {0}
private

Definition at line 149 of file blockassembler.h.

◆ nHeight

int BlockAssembler::nHeight {0}
private

Definition at line 153 of file blockassembler.h.

◆ nSizeShielded

unsigned int BlockAssembler::nSizeShielded {0}
private

Definition at line 157 of file blockassembler.h.

◆ pblock

CBlock* BlockAssembler::pblock {nullptr}
private

Definition at line 140 of file blockassembler.h.

◆ pblocktemplate

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

Definition at line 138 of file blockassembler.h.


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