6 #ifndef BITCOIN_MINER_H
7 #define BITCOIN_MINER_H
17 #include <boost/multi_index_container.hpp>
18 #include <boost/multi_index/ordered_index.hpp>
85 if (a->GetCountWithAncestors() != b->GetCountWithAncestors())
86 return a->GetCountWithAncestors() < b->GetCountWithAncestors();
91 typedef boost::multi_index_container<
93 boost::multi_index::indexed_by<
94 boost::multi_index::ordered_unique<
99 boost::multi_index::ordered_non_unique<
101 boost::multi_index::tag<ancestor_score>,
102 boost::multi_index::identity<CTxMemPoolModifiedEntry>,
108 typedef indexed_modified_transaction_set::nth_index<0>::type::iterator
modtxiter;
109 typedef indexed_modified_transaction_set::index<ancestor_score>::type::iterator
modtxscoreiter;
183 bool TestPackage(uint64_t packageSize, int64_t packageSigOpsCost)
const;
207 #endif // BITCOIN_MINER_H
void operator()(CTxMemPoolModifiedEntry &e)
indexed_modified_transaction_set::nth_index< 0 >::type::iterator modtxiter
bool TestPackageTransactions(const CTxMemPool::setEntries &package)
Perform checks on each transaction in a package: locktime, premature-witness, serialized size (if nec...
Comparator for CTxMemPool::txiter objects.
static Optional< int64_t > m_last_block_num_txs
uint64_t GetSizeWithAncestors() const
unsigned int nBlockMaxWeight
indexed_transaction_set::nth_index< 0 >::type::const_iterator txiter
void AddToBlock(CTxMemPool::txiter iter)
Add a tx to the block.
int UpdatePackagesForAdded(const CTxMemPool::setEntries &alreadyAdded, indexed_modified_transaction_set &mapModifiedTx) EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs)
Add descendants of given transactions to mapModifiedTx with ancestor state updated assuming given tra...
bool operator()(const CTxMemPool::txiter &a, const CTxMemPool::txiter &b) const
void onlyUnconfirmed(CTxMemPool::setEntries &testSet)
Remove confirmed (inBlock) entries from given set.
CTxMemPool::setEntries inBlock
std::unique_ptr< CBlockTemplate > pblocktemplate
std::set< txiter, CompareIteratorByHash > setEntries
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system...
bool operator()(const CTxMemPool::txiter &a, const CTxMemPool::txiter &b) const
result_type operator()(const CTxMemPoolModifiedEntry &entry) const
Transaction validation functions.
indexed_modified_transaction_set::index< ancestor_score >::type::iterator modtxscoreiter
BlockAssembler(const CTxMemPool &mempool, const CChainParams ¶ms)
int64_t CAmount
Amount in satoshis (Can be negative)
std::vector< int64_t > vTxSigOpsCost
CTxMemPool::txiter result_type
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 >, CompareTxMemPoolEntryByAncestorFee > >> indexed_modified_transaction_set
update_for_parent_inclusion(CTxMemPool::txiter it)
Generate a new block, without valid proof-of-work.
bool SkipMapTxEntry(CTxMemPool::txiter it, indexed_modified_transaction_set &mapModifiedTx, CTxMemPool::setEntries &failedTx) EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs)
Return true if given transaction from mapTx has already been evaluated, or if the transaction's cache...
void SortForBlock(const CTxMemPool::setEntries &package, std::vector< CTxMemPool::txiter > &sortedEntries)
Sort the package in an order that is valid to appear in a block.
std::unique_ptr< CBlockTemplate > CreateNewBlock(const CScript &scriptPubKeyIn)
Construct a new block template with coinbase to scriptPubKeyIn.
std::vector< CAmount > vTxFees
Parameters that influence chain consensus.
static Optional< int64_t > m_last_block_weight
int64_t UpdateTime(CBlockHeader *pblock, const Consensus::Params &consensusParams, const CBlockIndex *pindexPrev)
const CTxMemPool & m_mempool
uint64_t nSizeWithAncestors
uint64_t nBlockSigOpsCost
CAmount nModFeesWithAncestors
void RegenerateCommitments(CBlock &block)
Update an old GenerateCoinbaseCommitment from CreateNewBlock after the block txs have changed...
#define EXCLUSIVE_LOCKS_REQUIRED(...)
void addPackageTxs(int &nPackagesSelected, int &nDescendantsUpdated) EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs)
Add transactions based on feerate including unconfirmed ancestors Increments nPackagesSelected / nDes...
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
The block chain is a tree shaped structure starting with the genesis block at the root...
const CChainParams & Params()
Return the currently selected parameters.
Serialized script, used inside transaction inputs and outputs.
int64_t nSigOpCostWithAncestors
const CTransaction & GetTx() const
bool TestPackage(uint64_t packageSize, int64_t packageSigOpsCost) const
Test if a new package would "fit" in the block.
CAmount GetModFeesWithAncestors() const
Fee rate in satoshis per kilobyte: CAmount / kB.
void resetBlock()
Clear the block's state and prepare for assembling a new block.
CTxMemPoolModifiedEntry(CTxMemPool::txiter entry)
void IncrementExtraNonce(CBlock *pblock, const CBlockIndex *pindexPrev, unsigned int &nExtraNonce)
Modify the extranonce in a block.
std::vector< unsigned char > vchCoinbaseCommitment
The basic transaction that is broadcasted on the network and contained in blocks. ...
boost::optional< T > Optional
Substitute for C++17 std::optional.
static const bool DEFAULT_PRINTPRIORITY
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it...
int64_t GetModifiedFee() const