Changeset View
Changeset View
Standalone View
Standalone View
src/miner.h
Show All 23 Lines | |||||
static const bool DEFAULT_PRINTPRIORITY = false; | static const bool DEFAULT_PRINTPRIORITY = false; | ||||
struct CBlockTemplateEntry { | struct CBlockTemplateEntry { | ||||
CTransactionRef tx; | CTransactionRef tx; | ||||
//!< 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; | ||||
//!< Modified fees from mempool. Set by the prioritisetransaction rpc. | |||||
//!< We need this for ordering, but the above txFee for proper coinbase | |||||
//!< calculations. | |||||
Amount txModFee; | |||||
//!< 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; | ||||
//!< Track the "order" of a transaction in a package. (Order is >= 0) Larger | //!< Track the "order" of a transaction in a package. (Order is >= 0) Larger | ||||
//!< number means it has more dependencies. It is roughly the number of | //!< number means it has more dependencies. It is roughly the number of | ||||
//!< dependencies this transaction has. | //!< dependencies this transaction has. | ||||
uint64_t packageOrder; | uint64_t packageOrder; | ||||
//!< Estimated package fees (This is guaranteed to be >= real fees) | //!< Estimated package fees (This is guaranteed to be >= real fees) | ||||
Amount packageFee; | Amount packageFee; | ||||
//!< Estimated package size (This is guaranteed to be >= real size) | //!< Estimated package size (This is guaranteed to be >= real size) | ||||
size_t packageSize; | size_t packageSize; | ||||
//!< 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, Amount _modFees, | ||||
int64_t _sigOps) | uint64_t _size, int64_t _sigOps) | ||||
: tx(_tx), txFee(_fees), txSize(_size), txSigOps(_sigOps), | : tx(_tx), txFee(_fees), txModFee(_modFees), txSize(_size), | ||||
packageOrder(0), packageFee(_fees), packageSize(_size), | txSigOps(_sigOps), packageOrder(0), packageFee(_modFees), | ||||
packageSigOps(_sigOps) {} | packageSize(_size), packageSigOps(_sigOps) {} | ||||
// Calculate the feerate for this transaction. Use the minimum of the | // Calculate the feerate for this transaction. Use the minimum of the | ||||
// package feerate, or the transaction itself. Parents TXNs should never | // package feerate, or the transaction itself. Parents TXNs should never | ||||
// end up "paying for" child transactions. | // end up "paying for" child transactions. | ||||
CFeeRate FeeRate() const { | CFeeRate FeeRate() const { | ||||
// In order to avoid numerical errors, we reorder to use multiplication | // In order to avoid numerical errors, we reorder to use multiplication | ||||
// instead of vision. | // instead of vision. | ||||
return int64_t(txSize) * packageFee < int64_t(packageSize) * txFee | return int64_t(txSize) * packageFee < int64_t(packageSize) * txModFee | ||||
? CFeeRate(packageFee, packageSize) | ? CFeeRate(packageFee, packageSize) | ||||
: CFeeRate(txFee, txSize); | : CFeeRate(txModFee, txSize); | ||||
} | } | ||||
private: | private: | ||||
// Include a parent transactions accounting into our own. | // Include a parent transactions accounting into our own. | ||||
// We assume that this is used in topological order by BlockAssembler. | // We assume that this is used in topological order by BlockAssembler. | ||||
void AccountForParent(const CBlockTemplateEntry &parent) { | void AccountForParent(const CBlockTemplateEntry &parent) { | ||||
packageOrder = std::max(parent.packageOrder + 1, packageOrder); | packageOrder = std::max(parent.packageOrder + 1, packageOrder); | ||||
packageFee += parent.packageFee; | packageFee += parent.packageFee; | ||||
▲ Show 20 Lines • Show All 214 Lines • Show Last 20 Lines |