refactor: Inline CTxMemPoolEntry class's functions

This commit is contained in:
Hennadii Stepanov committed 2022-11-16 20:17:05 +00:00
1 parent 75bbe594e5
commit c8dc0e3eaa
4 files changed
+38 -57

No files matched your search

-2
View File
@@ -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 \
-49
View File
@@ -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);
}
+36 -4
View File
@@ -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>
@@ -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; }
+2 -2
View File
@@ -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