aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2022-11-16 20:10:28 +0000
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2022-11-16 20:17:05 +0000
commitc8dc0e3eaa9e0f956c5177bcb69632beb0d51770 (patch)
treeb542cbf7aac3143addb8ab0df55fc4e9e166d5d0 /src
parent75bbe594e54402ed248ecf2bdfe54e8283d20fff (diff)
downloadbitcoin-c8dc0e3eaa9e0f956c5177bcb69632beb0d51770.tar.xz
refactor: Inline `CTxMemPoolEntry` class's functions
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/txmempool_entry.cpp49
-rw-r--r--src/txmempool_entry.h46
3 files changed, 39 insertions, 58 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index c3790cd22e..1d905e0418 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -426,7 +426,6 @@ libbitcoin_node_a_SOURCES = \
torcontrol.cpp \
txdb.cpp \
txmempool.cpp \
- txmempool_entry.cpp \
txorphanage.cpp \
txrequest.cpp \
validation.cpp \
@@ -932,7 +931,6 @@ libbitcoinkernel_la_SOURCES = \
threadinterrupt.cpp \
txdb.cpp \
txmempool.cpp \
- txmempool_entry.cpp \
uint256.cpp \
util/check.cpp \
util/getuniquepath.cpp \
diff --git a/src/txmempool_entry.cpp b/src/txmempool_entry.cpp
deleted file mode 100644
index af7bca3f4d..0000000000
--- a/src/txmempool_entry.cpp
+++ /dev/null
@@ -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);
-}
diff --git a/src/txmempool_entry.h b/src/txmempool_entry.h
index c13f17f00d..dd71833200 100644
--- a/src/txmempool_entry.h
+++ b/src/txmempool_entry.h
@@ -6,8 +6,13 @@
#define BITCOIN_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/epochguard.h>
+#include <util/overflow.h>
#include <chrono>
#include <functional>
@@ -77,14 +82,14 @@ private:
const bool spendsCoinbase; //!< keep track of transactions that spend a coinbase
const int64_t sigOpCost; //!< Total sigop cost
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
// mempool; if we remove this transaction we must remove all of these
// descendants as well.
uint64_t nCountWithDescendants{1}; //!< number of descendant transactions
- uint64_t nSizeWithDescendants; //!< ... and size
- CAmount nModFeesWithDescendants; //!< ... and total fees (all including us)
+ uint64_t nSizeWithDescendants; //!< ... and size
+ CAmount nModFeesWithDescendants; //!< ... and total fees (all including us)
// Analogous statistics for ancestor transactions
uint64_t nCountWithAncestors{1};
@@ -96,12 +101,30 @@ public:
CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee,
int64_t time, unsigned int entry_height,
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; }
CTransactionRef GetSharedTx() const { return this->tx; }
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; }
std::chrono::seconds GetTime() const { return std::chrono::seconds{nTime}; }
unsigned int GetHeight() const { return entryHeight; }
@@ -115,9 +138,18 @@ public:
// Adjusts the ancestor state
void UpdateAncestorState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps);
// 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
- void UpdateLockPoints(const LockPoints& lp);
+ void UpdateLockPoints(const LockPoints& lp)
+ {
+ lockPoints = lp;
+ }
uint64_t GetCountWithDescendants() const { return nCountWithDescendants; }
uint64_t GetSizeWithDescendants() const { return nSizeWithDescendants; }