refactor: Inline CTxMemPoolEntry class's functions
This commit is contained in:
4 files changed
+41
-60
No files matched your search
@@ -426,7 +426,6 @@ libbitcoin_node_a_SOURCES = \
|
|||||||
torcontrol.cpp \
|
torcontrol.cpp \
|
||||||
txdb.cpp \
|
txdb.cpp \
|
||||||
txmempool.cpp \
|
txmempool.cpp \
|
||||||
txmempool_entry.cpp \
|
|
||||||
txorphanage.cpp \
|
txorphanage.cpp \
|
||||||
txrequest.cpp \
|
txrequest.cpp \
|
||||||
validation.cpp \
|
validation.cpp \
|
||||||
@@ -932,7 +931,6 @@ libbitcoinkernel_la_SOURCES = \
|
|||||||
threadinterrupt.cpp \
|
threadinterrupt.cpp \
|
||||||
txdb.cpp \
|
txdb.cpp \
|
||||||
txmempool.cpp \
|
txmempool.cpp \
|
||||||
txmempool_entry.cpp \
|
|
||||||
uint256.cpp \
|
uint256.cpp \
|
||||||
util/check.cpp \
|
util/check.cpp \
|
||||||
util/getuniquepath.cpp \
|
util/getuniquepath.cpp \
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
// Copyright (c) 2009-2022 The Bitcoin Core developers
|
|
||||||
// Distributed under the MIT software license, see the accompanying
|
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
||||||
|
|
||||||
#include <txmempool_entry.h>
|
|
||||||
|
|
||||||
#include <consensus/amount.h>
|
|
||||||
#include <consensus/validation.h>
|
|
||||||
#include <core_memusage.h>
|
|
||||||
#include <policy/policy.h>
|
|
||||||
#include <policy/settings.h>
|
|
||||||
#include <primitives/transaction.h>
|
|
||||||
#include <util/overflow.h>
|
|
||||||
|
|
||||||
CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee,
|
|
||||||
int64_t time, unsigned int entry_height,
|
|
||||||
bool spends_coinbase, int64_t sigops_cost, LockPoints lp)
|
|
||||||
: tx{tx},
|
|
||||||
nFee{fee},
|
|
||||||
nTxWeight(GetTransactionWeight(*tx)),
|
|
||||||
nUsageSize{RecursiveDynamicUsage(tx)},
|
|
||||||
nTime{time},
|
|
||||||
entryHeight{entry_height},
|
|
||||||
spendsCoinbase{spends_coinbase},
|
|
||||||
sigOpCost{sigops_cost},
|
|
||||||
m_modified_fee{nFee},
|
|
||||||
lockPoints{lp},
|
|
||||||
nSizeWithDescendants{GetTxSize()},
|
|
||||||
nModFeesWithDescendants{nFee},
|
|
||||||
nSizeWithAncestors{GetTxSize()},
|
|
||||||
nModFeesWithAncestors{nFee},
|
|
||||||
nSigOpCostWithAncestors{sigOpCost} {}
|
|
||||||
|
|
||||||
void CTxMemPoolEntry::UpdateModifiedFee(CAmount fee_diff)
|
|
||||||
{
|
|
||||||
nModFeesWithDescendants = SaturatingAdd(nModFeesWithDescendants, fee_diff);
|
|
||||||
nModFeesWithAncestors = SaturatingAdd(nModFeesWithAncestors, fee_diff);
|
|
||||||
m_modified_fee = SaturatingAdd(m_modified_fee, fee_diff);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CTxMemPoolEntry::UpdateLockPoints(const LockPoints& lp)
|
|
||||||
{
|
|
||||||
lockPoints = lp;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t CTxMemPoolEntry::GetTxSize() const
|
|
||||||
{
|
|
||||||
return GetVirtualTransactionSize(nTxWeight, sigOpCost, ::nBytesPerSigOp);
|
|
||||||
}
|
|
||||||
+39
-7
@@ -6,8 +6,13 @@
|
|||||||
#define BITCOIN_TXMEMPOOL_ENTRY_H
|
#define BITCOIN_TXMEMPOOL_ENTRY_H
|
||||||
|
|
||||||
#include <consensus/amount.h>
|
#include <consensus/amount.h>
|
||||||
|
#include <consensus/validation.h>
|
||||||
|
#include <core_memusage.h>
|
||||||
|
#include <policy/policy.h>
|
||||||
|
#include <policy/settings.h>
|
||||||
#include <primitives/transaction.h>
|
#include <primitives/transaction.h>
|
||||||
#include <util/epochguard.h>
|
#include <util/epochguard.h>
|
||||||
|
#include <util/overflow.h>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@@ -77,14 +82,14 @@ private:
|
|||||||
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
|
||||||
CAmount m_modified_fee; //!< Used for determining the priority of the transaction for mining in a block
|
CAmount m_modified_fee; //!< 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
|
||||||
// mempool; if we remove this transaction we must remove all of these
|
// mempool; if we remove this transaction we must remove all of these
|
||||||
// descendants as well.
|
// descendants as well.
|
||||||
uint64_t nCountWithDescendants{1}; //!< number of descendant transactions
|
uint64_t nCountWithDescendants{1}; //!< number of descendant transactions
|
||||||
uint64_t nSizeWithDescendants; //!< ... and size
|
uint64_t nSizeWithDescendants; //!< ... and size
|
||||||
CAmount nModFeesWithDescendants; //!< ... and total fees (all including us)
|
CAmount nModFeesWithDescendants; //!< ... and total fees (all including us)
|
||||||
|
|
||||||
// Analogous statistics for ancestor transactions
|
// Analogous statistics for ancestor transactions
|
||||||
uint64_t nCountWithAncestors{1};
|
uint64_t nCountWithAncestors{1};
|
||||||
@@ -96,12 +101,30 @@ public:
|
|||||||
CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee,
|
CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee,
|
||||||
int64_t time, unsigned int entry_height,
|
int64_t time, unsigned int entry_height,
|
||||||
bool spends_coinbase,
|
bool spends_coinbase,
|
||||||
int64_t sigops_cost, LockPoints lp);
|
int64_t sigops_cost, LockPoints lp)
|
||||||
|
: tx{tx},
|
||||||
|
nFee{fee},
|
||||||
|
nTxWeight(GetTransactionWeight(*tx)),
|
||||||
|
nUsageSize{RecursiveDynamicUsage(tx)},
|
||||||
|
nTime{time},
|
||||||
|
entryHeight{entry_height},
|
||||||
|
spendsCoinbase{spends_coinbase},
|
||||||
|
sigOpCost{sigops_cost},
|
||||||
|
m_modified_fee{nFee},
|
||||||
|
lockPoints{lp},
|
||||||
|
nSizeWithDescendants{GetTxSize()},
|
||||||
|
nModFeesWithDescendants{nFee},
|
||||||
|
nSizeWithAncestors{GetTxSize()},
|
||||||
|
nModFeesWithAncestors{nFee},
|
||||||
|
nSigOpCostWithAncestors{sigOpCost} {}
|
||||||
|
|
||||||
const CTransaction& GetTx() const { return *this->tx; }
|
const CTransaction& GetTx() const { return *this->tx; }
|
||||||
CTransactionRef GetSharedTx() const { return this->tx; }
|
CTransactionRef GetSharedTx() const { return this->tx; }
|
||||||
const CAmount& GetFee() const { return nFee; }
|
const CAmount& GetFee() const { return nFee; }
|
||||||
size_t GetTxSize() const;
|
size_t GetTxSize() const
|
||||||
|
{
|
||||||
|
return GetVirtualTransactionSize(nTxWeight, sigOpCost, ::nBytesPerSigOp);
|
||||||
|
}
|
||||||
size_t GetTxWeight() const { return nTxWeight; }
|
size_t GetTxWeight() const { return nTxWeight; }
|
||||||
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; }
|
||||||
@@ -115,9 +138,18 @@ 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 modified fees with descendants/ancestors.
|
// Updates the modified fees with descendants/ancestors.
|
||||||
void UpdateModifiedFee(CAmount fee_diff);
|
void UpdateModifiedFee(CAmount fee_diff)
|
||||||
|
{
|
||||||
|
nModFeesWithDescendants = SaturatingAdd(nModFeesWithDescendants, fee_diff);
|
||||||
|
nModFeesWithAncestors = SaturatingAdd(nModFeesWithAncestors, fee_diff);
|
||||||
|
m_modified_fee = SaturatingAdd(m_modified_fee, fee_diff);
|
||||||
|
}
|
||||||
|
|
||||||
// Update the LockPoints after a reorg
|
// Update the LockPoints after a reorg
|
||||||
void UpdateLockPoints(const LockPoints& lp);
|
void UpdateLockPoints(const LockPoints& lp)
|
||||||
|
{
|
||||||
|
lockPoints = lp;
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t GetCountWithDescendants() const { return nCountWithDescendants; }
|
uint64_t GetCountWithDescendants() const { return nCountWithDescendants; }
|
||||||
uint64_t GetSizeWithDescendants() const { return nSizeWithDescendants; }
|
uint64_t GetSizeWithDescendants() const { return nSizeWithDescendants; }
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ unsigned-integer-overflow:policy/fees.cpp
|
|||||||
unsigned-integer-overflow:prevector.h
|
unsigned-integer-overflow:prevector.h
|
||||||
unsigned-integer-overflow:script/interpreter.cpp
|
unsigned-integer-overflow:script/interpreter.cpp
|
||||||
unsigned-integer-overflow:txmempool.cpp
|
unsigned-integer-overflow:txmempool.cpp
|
||||||
unsigned-integer-overflow:txmempool_entry.cpp
|
unsigned-integer-overflow:txmempool_entry.h
|
||||||
implicit-integer-sign-change:compat/stdin.cpp
|
implicit-integer-sign-change:compat/stdin.cpp
|
||||||
implicit-integer-sign-change:compressor.h
|
implicit-integer-sign-change:compressor.h
|
||||||
implicit-integer-sign-change:crypto/
|
implicit-integer-sign-change:crypto/
|
||||||
@@ -63,7 +63,7 @@ implicit-integer-sign-change:script/bitcoinconsensus.cpp
|
|||||||
implicit-integer-sign-change:script/interpreter.cpp
|
implicit-integer-sign-change:script/interpreter.cpp
|
||||||
implicit-integer-sign-change:serialize.h
|
implicit-integer-sign-change:serialize.h
|
||||||
implicit-integer-sign-change:txmempool.cpp
|
implicit-integer-sign-change:txmempool.cpp
|
||||||
implicit-integer-sign-change:txmempool_entry.cpp
|
implicit-integer-sign-change:txmempool_entry.h
|
||||||
implicit-signed-integer-truncation:crypto/
|
implicit-signed-integer-truncation:crypto/
|
||||||
implicit-unsigned-integer-truncation:crypto/
|
implicit-unsigned-integer-truncation:crypto/
|
||||||
shift-base:arith_uint256.cpp
|
shift-base:arith_uint256.cpp
|
||||||
|
|||||||
Reference in new issue
Block a user