Changeset View
Changeset View
Standalone View
Standalone View
src/miner.h
Show First 20 Lines • Show All 118 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 for the results from TestForBlock */ | |||||
enum class TestForBlockResult : uint8_t { | |||||
deadalnix: You can probably declare this as a private local class in BlockAssembler, as the only function… | |||||
TXFits = 0, | |||||
TXCantFix = 1, | |||||
deadalnixUnsubmitted Not Done Inline ActionsTXCantFit ? deadalnix: TXCantFit ? | |||||
BlockFinished = 3, | |||||
}; | |||||
/** 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 11 Lines | private: | ||||
// Chain context for the block | // Chain context for the block | ||||
int nHeight; | int nHeight; | ||||
int64_t nLockTimeCutoff; | int64_t nLockTimeCutoff; | ||||
const Config *config; | const Config *config; | ||||
// Variables used for addPriorityTxs | // Variables used for addPriorityTxs | ||||
int lastFewTxs; | int lastFewTxs; | ||||
bool blockFinished; | |||||
public: | public: | ||||
BlockAssembler(const Config &_config); | BlockAssembler(const Config &_config); | ||||
/** 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 10 Lines | private: | ||||
void addPriorityTxs(); | void addPriorityTxs(); | ||||
/** 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); | ||||
// helper function for addPriorityTxs | // helper function for addPriorityTxs | ||||
/** Test if tx will still "fit" in the block */ | /** Test if tx will still "fit" in the block */ | ||||
bool TestForBlock(CTxMemPool::txiter iter); | TestForBlockResult TestForBlock(CTxMemPool::txiter iter); | ||||
/** Test if tx still has unconfirmed parents not yet in block */ | /** Test if tx still has unconfirmed parents not yet in block */ | ||||
bool isStillDependent(CTxMemPool::txiter iter); | bool isStillDependent(CTxMemPool::txiter iter); | ||||
// 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 packageSigOpsCost); | bool TestPackage(uint64_t packageSize, int64_t packageSigOpsCost); | ||||
Show All 28 Lines |
You can probably declare this as a private local class in BlockAssembler, as the only function using it is private anyway.