Changeset View
Changeset View
Standalone View
Standalone View
src/miner.h
Show First 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | private: | ||||
CTxMemPool::setEntries inBlock; | CTxMemPool::setEntries inBlock; | ||||
// Chain context for the block | // Chain context for the block | ||||
int nHeight; | int nHeight; | ||||
int64_t nLockTimeCutoff; | int64_t nLockTimeCutoff; | ||||
int64_t nMedianTimePast; | int64_t nMedianTimePast; | ||||
const CChainParams &chainParams; | const CChainParams &chainParams; | ||||
const CTxMemPool *mempool; | const CTxMemPool &m_mempool; | ||||
public: | public: | ||||
struct Options { | struct Options { | ||||
Options(); | Options(); | ||||
uint64_t nExcessiveBlockSize; | uint64_t nExcessiveBlockSize; | ||||
uint64_t nMaxGeneratedBlockSize; | uint64_t nMaxGeneratedBlockSize; | ||||
CFeeRate blockMinFeeRate; | CFeeRate blockMinFeeRate; | ||||
}; | }; | ||||
BlockAssembler(const Config &config, const CTxMemPool &_mempool); | BlockAssembler(const Config &config, const CTxMemPool &mempool); | ||||
BlockAssembler(const CChainParams ¶ms, const CTxMemPool &_mempool, | BlockAssembler(const CChainParams ¶ms, const CTxMemPool &mempool, | ||||
const Options &options); | const Options &options); | ||||
/** Construct a new block template with coinbase to scriptPubKeyIn */ | /** Construct a new block template with coinbase to scriptPubKeyIn */ | ||||
std::unique_ptr<CBlockTemplate> | std::unique_ptr<CBlockTemplate> | ||||
CreateNewBlock(const CScript &scriptPubKeyIn); | CreateNewBlock(const CScript &scriptPubKeyIn); | ||||
uint64_t GetMaxGeneratedBlockSize() const { return nMaxGeneratedBlockSize; } | uint64_t GetMaxGeneratedBlockSize() const { return nMaxGeneratedBlockSize; } | ||||
Show All 9 Lines | private: | ||||
// Methods for how to add transactions to a block. | // Methods for how to add transactions to a block. | ||||
/** | /** | ||||
* Add transactions based on feerate including unconfirmed ancestors. | * Add transactions based on feerate including unconfirmed ancestors. | ||||
* Increments nPackagesSelected / nDescendantsUpdated with corresponding | * Increments nPackagesSelected / nDescendantsUpdated with corresponding | ||||
* statistics from the package selection (for logging statistics). | * statistics from the package selection (for logging statistics). | ||||
*/ | */ | ||||
void addPackageTxs(int &nPackagesSelected, int &nDescendantsUpdated) | void addPackageTxs(int &nPackagesSelected, int &nDescendantsUpdated) | ||||
EXCLUSIVE_LOCKS_REQUIRED(mempool->cs); | EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs); | ||||
// helper functions for addPackageTxs() | // helper functions for addPackageTxs() | ||||
/** Remove confirmed (inBlock) entries from given set */ | /** Remove confirmed (inBlock) entries from given set */ | ||||
void onlyUnconfirmed(CTxMemPool::setEntries &testSet); | void onlyUnconfirmed(CTxMemPool::setEntries &testSet); | ||||
/** Test if a new package would "fit" in the block */ | /** Test if a new package would "fit" in the block */ | ||||
bool TestPackage(uint64_t packageSize, int64_t packageSigOpCount) const; | bool TestPackage(uint64_t packageSize, int64_t packageSigOpCount) const; | ||||
/** | /** | ||||
* Perform checks on each transaction in a package: | * Perform checks on each transaction in a package: | ||||
* locktime, serialized size (if necessary). These checks should always | * locktime, serialized size (if necessary). These checks should always | ||||
* succeed, and they're here only as an extra check in case of suboptimal | * succeed, and they're here only as an extra check in case of suboptimal | ||||
* node configuration. | * node configuration. | ||||
*/ | */ | ||||
bool TestPackageTransactions(const CTxMemPool::setEntries &package); | bool TestPackageTransactions(const CTxMemPool::setEntries &package); | ||||
/** | /** | ||||
* Return true if given transaction from mapTx has already been evaluated, | * Return true if given transaction from mapTx has already been evaluated, | ||||
* or if the transaction's cached data in mapTx is incorrect. | * or if the transaction's cached data in mapTx is incorrect. | ||||
*/ | */ | ||||
bool SkipMapTxEntry(CTxMemPool::txiter it, | bool SkipMapTxEntry(CTxMemPool::txiter it, | ||||
indexed_modified_transaction_set &mapModifiedTx, | indexed_modified_transaction_set &mapModifiedTx, | ||||
CTxMemPool::setEntries &failedTx) | CTxMemPool::setEntries &failedTx) | ||||
EXCLUSIVE_LOCKS_REQUIRED(mempool->cs); | EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs); | ||||
/** Sort the package in an order that is valid to appear in a block */ | /** Sort the package in an order that is valid to appear in a block */ | ||||
void SortForBlock(const CTxMemPool::setEntries &package, | void SortForBlock(const CTxMemPool::setEntries &package, | ||||
std::vector<CTxMemPool::txiter> &sortedEntries); | std::vector<CTxMemPool::txiter> &sortedEntries); | ||||
/** | /** | ||||
* Add descendants of given transactions to mapModifiedTx with ancestor | * Add descendants of given transactions to mapModifiedTx with ancestor | ||||
* state updated assuming given transactions are inBlock. Returns number of | * state updated assuming given transactions are inBlock. Returns number of | ||||
* updated descendants. | * updated descendants. | ||||
*/ | */ | ||||
int UpdatePackagesForAdded(const CTxMemPool::setEntries &alreadyAdded, | int UpdatePackagesForAdded(const CTxMemPool::setEntries &alreadyAdded, | ||||
indexed_modified_transaction_set &mapModifiedTx) | indexed_modified_transaction_set &mapModifiedTx) | ||||
EXCLUSIVE_LOCKS_REQUIRED(mempool->cs); | EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs); | ||||
}; | }; | ||||
/** Modify the extranonce in a block */ | /** Modify the extranonce in a block */ | ||||
void IncrementExtraNonce(CBlock *pblock, const CBlockIndex *pindexPrev, | void IncrementExtraNonce(CBlock *pblock, const CBlockIndex *pindexPrev, | ||||
uint64_t nExcessiveBlockSize, | uint64_t nExcessiveBlockSize, | ||||
unsigned int &nExtraNonce); | unsigned int &nExtraNonce); | ||||
int64_t UpdateTime(CBlockHeader *pblock, const CChainParams &chainParams, | int64_t UpdateTime(CBlockHeader *pblock, const CChainParams &chainParams, | ||||
const CBlockIndex *pindexPrev); | const CBlockIndex *pindexPrev); | ||||
#endif // BITCOIN_MINER_H | #endif // BITCOIN_MINER_H |