7 #ifndef PIVX_BLOCKASSEMBLER_H
8 #define PIVX_BLOCKASSEMBLER_H
15 #include "boost/multi_index_container.hpp"
16 #include "boost/multi_index/ordered_index.hpp"
92 if (a->GetCountWithAncestors() != b->GetCountWithAncestors())
93 return a->GetCountWithAncestors() < b->GetCountWithAncestors();
98 typedef boost::multi_index_container<
100 boost::multi_index::indexed_by<
101 boost::multi_index::ordered_unique<
106 boost::multi_index::ordered_non_unique<
108 boost::multi_index::tag<ancestor_score>,
109 boost::multi_index::identity<CTxMemPoolModifiedEntry>,
115 typedef indexed_modified_transaction_set::nth_index<0>::type::iterator
modtxiter;
116 typedef indexed_modified_transaction_set::index<ancestor_score>::type::iterator
modtxscoreiter;
167 bool fProofOfStake =
false,
168 std::vector<CStakeableOutput>* availableCoins =
nullptr,
169 bool fNoMempoolTx =
false,
170 bool fTestValidity =
true,
172 bool stopPoSOnNewBlock =
true,
173 bool fIncludeQfc =
true);
192 bool TestPackage(uint64_t packageSize,
unsigned int packageSigOps);
207 bool SolveBlock(std::shared_ptr<CBlock>& pblock,
int nHeight);
208 void IncrementExtraNonce(std::shared_ptr<CBlock>& pblock,
int nHeight,
unsigned int& nExtraNonce);
int64_t CAmount
Amount in PIV (Can be negative)
indexed_modified_transaction_set::nth_index< 0 >::type::iterator modtxiter
void IncrementExtraNonce(std::shared_ptr< CBlock > &pblock, int nHeight, unsigned int &nExtraNonce)
bool SolveBlock(std::shared_ptr< CBlock > &pblock, int nHeight)
Modify the nonce/extranonce in a block.
int32_t ComputeBlockVersion(const Consensus::Params &consensusParams, int nHeight)
bool CreateCoinbaseTx(CBlock *pblock, const CScript &scriptPubKeyIn, CBlockIndex *pindexPrev)
indexed_modified_transaction_set::index< ancestor_score >::type::iterator modtxscoreiter
int64_t UpdateTime(CBlockHeader *pblock, const Consensus::Params &consensusParams, const CBlockIndex *pindexPrev)
uint256 CalculateSaplingTreeRoot(CBlock *pblock, int nHeight, const CChainParams &chainparams)
boost::multi_index_container< CTxMemPoolModifiedEntry, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< modifiedentry_iter, CompareCTxMemPoolIter >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ancestor_score >, boost::multi_index::identity< CTxMemPoolModifiedEntry >, CompareModifiedEntry > >> indexed_modified_transaction_set
void AddToBlock(CTxMemPool::txiter iter)
Add a tx to the block.
std::unique_ptr< CBlockTemplate > 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.
CTxMemPool::setEntries inBlock
void addPackageTxs()
Add transactions based on feerate including unconfirmed ancestors.
bool TestPackageFinality(const CTxMemPool::setEntries &package)
Test if a set of transactions are all final.
unsigned int nBlockMaxSize
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.
void onlyUnconfirmed(CTxMemPool::setEntries &testSet)
Remove confirmed (inBlock) entries from given set.
void appendSaplingTreeRoot()
Add the tip updated incremental merkle tree to the header.
BlockAssembler(const CChainParams &chainparams, const bool defaultPrintPriority)
unsigned int nSizeShielded
void resetBlock()
Clear the block's state and prepare for assembling a new block.
std::unique_ptr< CBlockTemplate > pblocktemplate
const CChainParams & chainparams
void UpdatePackagesForAdded(const CTxMemPool::setEntries &alreadyAdded, indexed_modified_transaction_set &mapModifiedTx)
Add descendants of given transactions to mapModifiedTx with ancestor state updated assuming given tra...
unsigned int nBlockSigOps
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 cache...
const bool defaultPrintPriority
bool TestPackage(uint64_t packageSize, unsigned int packageSigOps)
Test if a new package would "fit" in the block.
The block chain is a tree shaped structure starting with the genesis block at the root,...
CChainParams defines various tweakable parameters of a given instance of the PIVX system.
A key allocated from the key pool.
Serialized script, used inside transaction inputs and outputs.
std::set< txiter, CompareIteratorByHash > setEntries
indexed_transaction_set::nth_index< 0 >::type::iterator txiter
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,...
std::vector< int64_t > vTxSigOps
std::vector< CAmount > vTxFees
A mutable version of CTransaction.
CTxMemPoolModifiedEntry(CTxMemPool::txiter entry)
unsigned int nSigOpCountWithAncestors
uint64_t nSizeWithAncestors
CAmount nModFeesWithAncestors
Comparator for CTxMemPool::txiter objects.
bool operator()(const CTxMemPool::txiter &a, const CTxMemPool::txiter &b) const
bool operator()(const CTxMemPoolModifiedEntry &a, const CTxMemPoolModifiedEntry &b) const
bool operator()(const CTxMemPool::txiter &a, const CTxMemPool::txiter &b) const
Parameters that influence chain consensus.
result_type operator()(const CTxMemPoolModifiedEntry &entry) const
CTxMemPool::txiter result_type
update_for_parent_inclusion(CTxMemPool::txiter it)
void operator()(CTxMemPoolModifiedEntry &e)