Changeset View
Changeset View
Standalone View
Standalone View
src/miner.h
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | struct CBlockTemplateEntry { | ||||
//!< Estimated package sigops (This is guaranteed to be >= real sigops) | //!< Estimated package sigops (This is guaranteed to be >= real sigops) | ||||
uint64_t packageSigOps; | uint64_t packageSigOps; | ||||
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), | ||||
packageOrder(0), packageFee(_fees), packageSize(_size), | packageOrder(0), packageFee(_fees), packageSize(_size), | ||||
packageSigOps(_sigOps) {} | packageSigOps(_sigOps) {} | ||||
/** | |||||
* Calculate the feerate for this transaction. Use the minimum of the | |||||
* package feerate, or the transaction itself. Parents TXNs should never | |||||
* end up "paying for" child transactions. | |||||
*/ | |||||
CFeeRate FeeRate() const { | |||||
// In order to avoid numerical errors, we reorder to use multiplication | |||||
// instead of vision. | |||||
return int64_t(txSize) * packageFee < int64_t(packageSize) * txFee | |||||
? CFeeRate(packageFee, packageSize) | |||||
: CFeeRate(txFee, txSize); | |||||
} | |||||
private: | |||||
/** | |||||
* Include a parent transactions accounting into our own. | |||||
* We assume that this is used in topological order by BlockAssembler. | |||||
*/ | |||||
void AccountForParent(const CBlockTemplateEntry &parent) { | |||||
packageOrder = std::max(parent.packageOrder + 1, packageOrder); | |||||
packageFee += parent.packageFee; | |||||
packageSize += parent.packageSize; | |||||
packageSigOps += parent.packageSigOps; | |||||
} | |||||
friend class BlockAssembler; | |||||
friend struct CBlockTemplateEntryTest; | |||||
}; | }; | ||||
struct CBlockTemplate { | struct CBlockTemplate { | ||||
CBlock block; | CBlock block; | ||||
std::vector<CBlockTemplateEntry> entries; | std::vector<CBlockTemplateEntry> entries; | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 196 Lines • Show Last 20 Lines |