Changeset View
Changeset View
Standalone View
Standalone View
src/miner.h
Show All 26 Lines | struct CBlockTemplateEntry { | ||||
//!< Total real fees paid by the transaction and cached to avoid parent | //!< Total real fees paid by the transaction and cached to avoid parent | ||||
//!< lookup | //!< lookup | ||||
Amount txFee; | Amount txFee; | ||||
//!< Cached total size of the transaction to avoid reserializing transaction | //!< Cached total size of the transaction to avoid reserializing transaction | ||||
size_t txSize; | size_t txSize; | ||||
//!< Cached total number of SigOps | //!< Cached total number of SigOps | ||||
uint64_t txSigOps; | uint64_t txSigOps; | ||||
CBlockTemplateEntry() {} | |||||
CBlockTemplateEntry(CTransactionRef _tx, Amount _fees, uint64_t _size, | CBlockTemplateEntry(CTransactionRef _tx, Amount _fees, uint64_t _size, | ||||
int64_t _sigOps) | int64_t _sigOps) | ||||
: tx(_tx), txFee(_fees), txSize(_size), txSigOps(_sigOps) {} | : tx(_tx), txFee(_fees), txSize(_size), txSigOps(_sigOps) {} | ||||
}; | }; | ||||
struct CBlockTemplate { | struct CBlockTemplate { | ||||
CBlock block; | CBlock block; | ||||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | void operator()(CTxMemPoolModifiedEntry &e) { | ||||
e.nModFeesWithAncestors -= iter->GetFee(); | e.nModFeesWithAncestors -= iter->GetFee(); | ||||
e.nSizeWithAncestors -= iter->GetTxSize(); | e.nSizeWithAncestors -= iter->GetTxSize(); | ||||
e.nSigOpCountWithAncestors -= iter->GetSigOpCount(); | e.nSigOpCountWithAncestors -= iter->GetSigOpCount(); | ||||
} | } | ||||
CTxMemPool::txiter iter; | CTxMemPool::txiter iter; | ||||
}; | }; | ||||
enum BlockAssemblerFlags { | |||||
NONE = 0, | |||||
EMPTY_BLOCK_ON_FAILURE = 1, | |||||
}; | |||||
/** Generate a new block, without valid proof-of-work */ | /** Generate a new block, without valid proof-of-work */ | ||||
class BlockAssembler { | class BlockAssembler { | ||||
private: | private: | ||||
// The constructed block template | // The constructed block template | ||||
std::unique_ptr<CBlockTemplate> pblocktemplate; | std::unique_ptr<CBlockTemplate> pblocktemplate; | ||||
// A convenience pointer that always refers to the CBlock in pblocktemplate | // A convenience pointer that always refers to the CBlock in pblocktemplate | ||||
CBlock *pblock; | CBlock *pblock; | ||||
Show All 18 Lines | private: | ||||
// Variables used for addPriorityTxs | // Variables used for addPriorityTxs | ||||
int lastFewTxs; | int lastFewTxs; | ||||
public: | public: | ||||
BlockAssembler(const Config &_config, const CTxMemPool &mempool); | BlockAssembler(const Config &_config, const CTxMemPool &mempool); | ||||
/** 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, | ||||
const BlockAssemblerFlags &flags = EMPTY_BLOCK_ON_FAILURE); | |||||
uint64_t GetMaxGeneratedBlockSize() const { return nMaxGeneratedBlockSize; } | uint64_t GetMaxGeneratedBlockSize() const { return nMaxGeneratedBlockSize; } | ||||
private: | private: | ||||
// utility functions | // utility functions | ||||
/** Clear the block's state and prepare for assembling a new block */ | /** Clear the block's state and prepare for assembling a new block */ | ||||
void resetBlock(); | void resetBlock(); | ||||
/** Add a tx to the block */ | /** Add a tx to the block */ | ||||
▲ Show 20 Lines • Show All 67 Lines • Show Last 20 Lines |