mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
Make CTxMemPoolEntry derive from TxGraph::Ref
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
static void AddTx(const CTransactionRef& tx, const CAmount& fee, CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs)
|
||||
{
|
||||
LockPoints lp;
|
||||
AddToMempool(pool, CTxMemPoolEntry(tx, fee, /*time=*/0, /*entry_height=*/1, /*entry_sequence=*/0, /*spends_coinbase=*/false, /*sigops_cost=*/4, lp));
|
||||
AddToMempool(pool, CTxMemPoolEntry(TxGraph::Ref(), tx, fee, /*time=*/0, /*entry_height=*/1, /*entry_sequence=*/0, /*spends_coinbase=*/false, /*sigops_cost=*/4, lp));
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -29,7 +29,7 @@ static void AddTx(const CTransactionRef& tx, CTxMemPool& pool) EXCLUSIVE_LOCKS_R
|
||||
unsigned int sigOpCost{4};
|
||||
uint64_t fee{0};
|
||||
LockPoints lp;
|
||||
AddToMempool(pool, CTxMemPoolEntry(
|
||||
AddToMempool(pool, CTxMemPoolEntry(TxGraph::Ref(),
|
||||
tx, fee, nTime, nHeight, sequence,
|
||||
spendsCoinbase, sigOpCost, lp));
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ static void AddTx(const CTransactionRef& tx, const CAmount& nFee, CTxMemPool& po
|
||||
bool spendsCoinbase = false;
|
||||
unsigned int sigOpCost = 4;
|
||||
LockPoints lp;
|
||||
AddToMempool(pool, CTxMemPoolEntry(
|
||||
AddToMempool(pool, CTxMemPoolEntry(TxGraph::Ref(),
|
||||
tx, nFee, nTime, nHeight, sequence,
|
||||
spendsCoinbase, sigOpCost, lp));
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ static void AddTx(const CTransactionRef& tx, CTxMemPool& pool) EXCLUSIVE_LOCKS_R
|
||||
bool spendsCoinbase = false;
|
||||
unsigned int sigOpCost = 4;
|
||||
LockPoints lp;
|
||||
AddToMempool(pool, CTxMemPoolEntry(tx, 1000, nTime, nHeight, sequence, spendsCoinbase, sigOpCost, lp));
|
||||
AddToMempool(pool, CTxMemPoolEntry(TxGraph::Ref(), tx, 1000, nTime, nHeight, sequence, spendsCoinbase, sigOpCost, lp));
|
||||
}
|
||||
|
||||
struct Available {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
static void AddTx(const CTransactionRef& tx, const CAmount& fee, CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs)
|
||||
{
|
||||
LockPoints lp;
|
||||
AddToMempool(pool, CTxMemPoolEntry(tx, fee, /*time=*/0, /*entry_height=*/1, /*entry_sequence=*/0, /*spends_coinbase=*/false, /*sigops_cost=*/4, lp));
|
||||
AddToMempool(pool, CTxMemPoolEntry(TxGraph::Ref(), tx, fee, /*time=*/0, /*entry_height=*/1, /*entry_sequence=*/0, /*spends_coinbase=*/false, /*sigops_cost=*/4, lp));
|
||||
}
|
||||
|
||||
static void RpcMempool(benchmark::Bench& bench)
|
||||
|
||||
@@ -58,6 +58,7 @@ add_library(bitcoinkernel
|
||||
../support/lockedpool.cpp
|
||||
../sync.cpp
|
||||
../txdb.cpp
|
||||
../txgraph.cpp
|
||||
../txmempool.cpp
|
||||
../uint256.cpp
|
||||
../util/chaintype.cpp
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <policy/policy.h>
|
||||
#include <policy/settings.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <txgraph.h>
|
||||
#include <util/epochguard.h>
|
||||
#include <util/overflow.h>
|
||||
|
||||
@@ -62,7 +63,7 @@ struct CompareIteratorByHash {
|
||||
*
|
||||
*/
|
||||
|
||||
class CTxMemPoolEntry
|
||||
class CTxMemPoolEntry : public TxGraph::Ref
|
||||
{
|
||||
public:
|
||||
typedef std::reference_wrapper<const CTxMemPoolEntry> CTxMemPoolEntryRef;
|
||||
@@ -103,11 +104,13 @@ private:
|
||||
int64_t nSigOpCostWithAncestors;
|
||||
|
||||
public:
|
||||
CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee,
|
||||
virtual ~CTxMemPoolEntry() = default;
|
||||
CTxMemPoolEntry(TxGraph::Ref&& ref, const CTransactionRef& tx, CAmount fee,
|
||||
int64_t time, unsigned int entry_height, uint64_t entry_sequence,
|
||||
bool spends_coinbase,
|
||||
int64_t sigops_cost, LockPoints lp)
|
||||
: tx{tx},
|
||||
: TxGraph::Ref(std::move(ref)),
|
||||
tx{tx},
|
||||
nFee{fee},
|
||||
nTxWeight{GetTransactionWeight(*tx)},
|
||||
nUsageSize{RecursiveDynamicUsage(tx)},
|
||||
|
||||
@@ -720,7 +720,7 @@ public:
|
||||
{
|
||||
if (!m_node.mempool) return {};
|
||||
LockPoints lp;
|
||||
CTxMemPoolEntry entry(tx, 0, 0, 0, 0, false, 0, lp);
|
||||
CTxMemPoolEntry entry(TxGraph::Ref(), tx, 0, 0, 0, 0, false, 0, lp);
|
||||
LOCK(m_node.mempool->cs);
|
||||
return m_node.mempool->CheckPackageLimits({tx}, entry.GetTxSize());
|
||||
}
|
||||
|
||||
@@ -27,5 +27,5 @@ CTxMemPoolEntry ConsumeTxMemPoolEntry(FuzzedDataProvider& fuzzed_data_provider,
|
||||
const auto entry_height{fuzzed_data_provider.ConsumeIntegralInRange<uint32_t>(0, max_height)};
|
||||
const bool spends_coinbase = fuzzed_data_provider.ConsumeBool();
|
||||
const unsigned int sig_op_cost = fuzzed_data_provider.ConsumeIntegralInRange<unsigned int>(0, MAX_BLOCK_SIGOPS_COST);
|
||||
return CTxMemPoolEntry{MakeTransactionRef(tx), fee, time, entry_height, entry_sequence, spends_coinbase, sig_op_cost, {}};
|
||||
return CTxMemPoolEntry{TxGraph::Ref(), MakeTransactionRef(tx), fee, time, entry_height, entry_sequence, spends_coinbase, sig_op_cost, {}};
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CMutableTransaction& tx) co
|
||||
|
||||
CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CTransactionRef& tx) const
|
||||
{
|
||||
return CTxMemPoolEntry{tx, nFee, TicksSinceEpoch<std::chrono::seconds>(time), nHeight, m_sequence, spendsCoinbase, sigOpCost, lp};
|
||||
return CTxMemPoolEntry{TxGraph::Ref(), tx, nFee, TicksSinceEpoch<std::chrono::seconds>(time), nHeight, m_sequence, spendsCoinbase, sigOpCost, lp};
|
||||
}
|
||||
|
||||
std::optional<std::string> CheckPackageMempoolAcceptResult(const Package& txns,
|
||||
|
||||
@@ -1386,7 +1386,7 @@ CTxMemPool::ChangeSet::TxHandle CTxMemPool::ChangeSet::StageAddition(const CTran
|
||||
{
|
||||
LOCK(m_pool->cs);
|
||||
Assume(m_to_add.find(tx->GetHash()) == m_to_add.end());
|
||||
auto newit = m_to_add.emplace(tx, fee, time, entry_height, entry_sequence, spends_coinbase, sigops_cost, lp).first;
|
||||
auto newit = m_to_add.emplace(TxGraph::Ref(), tx, fee, time, entry_height, entry_sequence, spends_coinbase, sigops_cost, lp).first;
|
||||
CAmount delta{0};
|
||||
m_pool->ApplyDelta(tx->GetHash(), delta);
|
||||
if (delta) m_to_add.modify(newit, [&delta](CTxMemPoolEntry& e) { e.UpdateModifiedFee(delta); });
|
||||
|
||||
Reference in New Issue
Block a user