mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-29 13:32:33 +02:00
Merge bitcoin/bitcoin#24625: Replace struct update_fee_delta with lambda
fa84a49526
Use CAmount for fee delta and modified fee (MarcoFalke)fa8857c3f7
Replace struct update_fee_delta with lambda (MarcoFalke) Pull request description: The same was done for another struct ine177fcab38
. Also, change type of feeDelta from int64_t to CAmount. ACKs for top commit: hebasto: re-ACKfa84a49526
promag: Code review ACKfa84a49526
. Tree-SHA512: 2b9ee449d348b0f685793a35c6dd3c57ed97fdf707a89495a0518bb332f407303b48723e667351e96f2b698e0a2ade27095517a3accd926d4ec85e58d6fd441f
This commit is contained in:
commit
0a14a16efe
@ -45,7 +45,7 @@ struct CTxMemPoolModifiedEntry {
|
|||||||
nSigOpCostWithAncestors = entry->GetSigOpCostWithAncestors();
|
nSigOpCostWithAncestors = entry->GetSigOpCostWithAncestors();
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t GetModifiedFee() const { return iter->GetModifiedFee(); }
|
CAmount GetModifiedFee() const { return iter->GetModifiedFee(); }
|
||||||
uint64_t GetSizeWithAncestors() const { return nSizeWithAncestors; }
|
uint64_t GetSizeWithAncestors() const { return nSizeWithAncestors; }
|
||||||
CAmount GetModFeesWithAncestors() const { return nModFeesWithAncestors; }
|
CAmount GetModFeesWithAncestors() const { return nModFeesWithAncestors; }
|
||||||
size_t GetTxSize() const { return iter->GetTxSize(); }
|
size_t GetTxSize() const { return iter->GetTxSize(); }
|
||||||
|
@ -54,16 +54,6 @@ struct update_ancestor_state
|
|||||||
int64_t modifySigOpsCost;
|
int64_t modifySigOpsCost;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct update_fee_delta
|
|
||||||
{
|
|
||||||
explicit update_fee_delta(int64_t _feeDelta) : feeDelta(_feeDelta) { }
|
|
||||||
|
|
||||||
void operator() (CTxMemPoolEntry &e) { e.UpdateFeeDelta(feeDelta); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
int64_t feeDelta;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool TestLockPointValidity(CChain& active_chain, const LockPoints& lp)
|
bool TestLockPointValidity(CChain& active_chain, const LockPoints& lp)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
@ -99,7 +89,7 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee,
|
|||||||
nModFeesWithAncestors{nFee},
|
nModFeesWithAncestors{nFee},
|
||||||
nSigOpCostWithAncestors{sigOpCost} {}
|
nSigOpCostWithAncestors{sigOpCost} {}
|
||||||
|
|
||||||
void CTxMemPoolEntry::UpdateFeeDelta(int64_t newFeeDelta)
|
void CTxMemPoolEntry::UpdateFeeDelta(CAmount newFeeDelta)
|
||||||
{
|
{
|
||||||
nModFeesWithDescendants += newFeeDelta - feeDelta;
|
nModFeesWithDescendants += newFeeDelta - feeDelta;
|
||||||
nModFeesWithAncestors += newFeeDelta - feeDelta;
|
nModFeesWithAncestors += newFeeDelta - feeDelta;
|
||||||
@ -496,7 +486,7 @@ void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAnces
|
|||||||
CAmount delta{0};
|
CAmount delta{0};
|
||||||
ApplyDelta(entry.GetTx().GetHash(), delta);
|
ApplyDelta(entry.GetTx().GetHash(), delta);
|
||||||
if (delta) {
|
if (delta) {
|
||||||
mapTx.modify(newit, update_fee_delta(delta));
|
mapTx.modify(newit, [&delta](CTxMemPoolEntry& e) { e.UpdateFeeDelta(delta); });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update cachedInnerUsage to include contained transaction's usage.
|
// Update cachedInnerUsage to include contained transaction's usage.
|
||||||
@ -931,7 +921,7 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD
|
|||||||
delta += nFeeDelta;
|
delta += nFeeDelta;
|
||||||
txiter it = mapTx.find(hash);
|
txiter it = mapTx.find(hash);
|
||||||
if (it != mapTx.end()) {
|
if (it != mapTx.end()) {
|
||||||
mapTx.modify(it, update_fee_delta(delta));
|
mapTx.modify(it, [&delta](CTxMemPoolEntry& e) { e.UpdateFeeDelta(delta); });
|
||||||
// Now update all ancestors' modified fees with descendants
|
// Now update all ancestors' modified fees with descendants
|
||||||
setEntries setAncestors;
|
setEntries setAncestors;
|
||||||
uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
|
uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
|
||||||
|
@ -101,7 +101,7 @@ private:
|
|||||||
const unsigned int entryHeight; //!< Chain height when entering the mempool
|
const unsigned int entryHeight; //!< Chain height when entering the mempool
|
||||||
const bool spendsCoinbase; //!< keep track of transactions that spend a coinbase
|
const bool spendsCoinbase; //!< keep track of transactions that spend a coinbase
|
||||||
const int64_t sigOpCost; //!< Total sigop cost
|
const int64_t sigOpCost; //!< Total sigop cost
|
||||||
int64_t feeDelta{0}; //!< Used for determining the priority of the transaction for mining in a block
|
CAmount feeDelta{0}; //!< Used for determining the priority of the transaction for mining in a block
|
||||||
LockPoints lockPoints; //!< Track the height and time at which tx was final
|
LockPoints lockPoints; //!< Track the height and time at which tx was final
|
||||||
|
|
||||||
// Information about descendants of this transaction that are in the
|
// Information about descendants of this transaction that are in the
|
||||||
@ -131,7 +131,7 @@ public:
|
|||||||
std::chrono::seconds GetTime() const { return std::chrono::seconds{nTime}; }
|
std::chrono::seconds GetTime() const { return std::chrono::seconds{nTime}; }
|
||||||
unsigned int GetHeight() const { return entryHeight; }
|
unsigned int GetHeight() const { return entryHeight; }
|
||||||
int64_t GetSigOpCost() const { return sigOpCost; }
|
int64_t GetSigOpCost() const { return sigOpCost; }
|
||||||
int64_t GetModifiedFee() const { return nFee + feeDelta; }
|
CAmount GetModifiedFee() const { return nFee + feeDelta; }
|
||||||
size_t DynamicMemoryUsage() const { return nUsageSize; }
|
size_t DynamicMemoryUsage() const { return nUsageSize; }
|
||||||
const LockPoints& GetLockPoints() const { return lockPoints; }
|
const LockPoints& GetLockPoints() const { return lockPoints; }
|
||||||
|
|
||||||
@ -140,8 +140,8 @@ public:
|
|||||||
// Adjusts the ancestor state
|
// Adjusts the ancestor state
|
||||||
void UpdateAncestorState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps);
|
void UpdateAncestorState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps);
|
||||||
// Updates the fee delta used for mining priority score, and the
|
// Updates the fee delta used for mining priority score, and the
|
||||||
// modified fees with descendants.
|
// modified fees with descendants/ancestors.
|
||||||
void UpdateFeeDelta(int64_t feeDelta);
|
void UpdateFeeDelta(CAmount newFeeDelta);
|
||||||
// Update the LockPoints after a reorg
|
// Update the LockPoints after a reorg
|
||||||
void UpdateLockPoints(const LockPoints& lp);
|
void UpdateLockPoints(const LockPoints& lp);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user