Fabcoin Core  0.16.2
P2P Digital Currency
Classes | Public Member Functions | Public Attributes | 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, int64_t *pTotalFees=0, int32_t nTime=0, int32_t nTimeLimit=0)
 Construct a new block template with coinbase to scriptPubKeyIn. More...
 

Public Attributes

ByteCodeExecResult bceResult
 Construct a new block template with coinbase to scriptPubKeyIn. More...
 
uint64_t minGasPrice = 1
 
uint64_t hardBlockGasLimit
 
uint64_t softBlockGasLimit
 
uint64_t txGasLimit
 
CMutableTransaction originalRewardTx
 
int32_t nTimeLimit
 

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...
 
bool AttemptToAddContractToBlock (CTxMemPool::txiter iter, uint64_t minGasPrice)
 
void addPackageTxs (int &nPackagesSelected, int &nDescendantsUpdated, uint64_t minGasPrice)
 Add transactions based on feerate including unconfirmed ancestors Increments nPackagesSelected / nDescendantsUpdated with corresponding statistics from the package selection (for logging statistics). More...
 
void RebuildRefundTransaction ()
 Rebuild the coinbase/coinstake transaction to account for new gas refunds. More...
 
void onlyUnconfirmed (CTxMemPool::setEntries &testSet)
 Remove confirmed (inBlock) entries from given set. More...
 
bool TestPackage (uint64_t packageSize, int64_t packageSigOpsCost)
 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 187 of file miner.h.

Constructor & Destructor Documentation

BlockAssembler::BlockAssembler ( const CChainParams params)

Definition at line 121 of file miner.cpp.

Here is the caller graph for this function:

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

Definition at line 94 of file miner.cpp.

Here is the call graph for this function:

Member Function Documentation

void BlockAssembler::addPackageTxs ( int &  nPackagesSelected,
int &  nDescendantsUpdated,
uint64_t  minGasPrice 
)
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 554 of file miner.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Add a tx to the block.

Definition at line 472 of file miner.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool BlockAssembler::AttemptToAddContractToBlock ( CTxMemPool::txiter  iter,
uint64_t  minGasPrice 
)
private

Definition at line 337 of file miner.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

std::unique_ptr< CBlockTemplate > BlockAssembler::CreateNewBlock ( const CScript scriptPubKeyIn,
bool  fMineWitnessTx = true,
int64_t *  pTotalFees = 0,
int32_t  nTime = 0,
int32_t  nTimeLimit = 0 
)

Construct a new block template with coinbase to scriptPubKeyIn.

!! LogPrintf("CreateNewBlock(): block weight: %u txs: %u fees: %ld sigops %d\n", GetBlockWeight(*pblock), nBlockTx, nFees, nBlockSigOpsCost);

Definition at line 153 of file miner.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Remove confirmed (inBlock) entries from given set.

Definition at line 299 of file miner.cpp.

Here is the caller graph for this function:

void BlockAssembler::RebuildRefundTransaction ( )
private

Rebuild the coinbase/coinstake transaction to account for new gas refunds.

Definition at line 137 of file miner.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void BlockAssembler::resetBlock ( )
private

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

Definition at line 123 of file miner.cpp.

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the caller graph for this function:

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

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

Definition at line 312 of file miner.cpp.

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

ByteCodeExecResult BlockAssembler::bceResult

Construct a new block template with coinbase to scriptPubKeyIn.

Definition at line 226 of file miner.h.

CFeeRate BlockAssembler::blockMinFeeRate
private

Definition at line 198 of file miner.h.

const CChainParams& BlockAssembler::chainparams
private

Definition at line 210 of file miner.h.

bool BlockAssembler::fIncludeWitness
private

Definition at line 196 of file miner.h.

uint64_t BlockAssembler::hardBlockGasLimit

Definition at line 228 of file miner.h.

CTxMemPool::setEntries BlockAssembler::inBlock
private

Definition at line 205 of file miner.h.

uint64_t BlockAssembler::minGasPrice = 1

Definition at line 227 of file miner.h.

unsigned int BlockAssembler::nBlockMaxWeight
private

Definition at line 197 of file miner.h.

uint64_t BlockAssembler::nBlockSigOpsCost
private

Definition at line 203 of file miner.h.

uint64_t BlockAssembler::nBlockTx
private

Definition at line 202 of file miner.h.

uint64_t BlockAssembler::nBlockWeight
private

Definition at line 201 of file miner.h.

CAmount BlockAssembler::nFees
private

Definition at line 204 of file miner.h.

int BlockAssembler::nHeight
private

Definition at line 208 of file miner.h.

int64_t BlockAssembler::nLockTimeCutoff
private

Definition at line 209 of file miner.h.

int32_t BlockAssembler::nTimeLimit

Definition at line 237 of file miner.h.

CMutableTransaction BlockAssembler::originalRewardTx

Definition at line 234 of file miner.h.

CBlock* BlockAssembler::pblock
private

Definition at line 193 of file miner.h.

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

Definition at line 191 of file miner.h.

uint64_t BlockAssembler::softBlockGasLimit

Definition at line 229 of file miner.h.

uint64_t BlockAssembler::txGasLimit

Definition at line 230 of file miner.h.


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