Make CTxMemPoolEntry derive from TxGraph::Ref
This commit is contained in:
1 parent
92b0079fe3
commit
29a94d5b2f
11 files changed
+16
-12
No files matched your search
@@ -22,7 +22,7 @@
|
|||||||
static void AddTx(const CTransactionRef& tx, const CAmount& fee, CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs)
|
static void AddTx(const CTransactionRef& tx, const CAmount& fee, CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs)
|
||||||
{
|
{
|
||||||
LockPoints lp;
|
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 {
|
namespace {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ static void AddTx(const CTransactionRef& tx, CTxMemPool& pool) EXCLUSIVE_LOCKS_R
|
|||||||
unsigned int sigOpCost{4};
|
unsigned int sigOpCost{4};
|
||||||
uint64_t fee{0};
|
uint64_t fee{0};
|
||||||
LockPoints lp;
|
LockPoints lp;
|
||||||
AddToMempool(pool, CTxMemPoolEntry(
|
AddToMempool(pool, CTxMemPoolEntry(TxGraph::Ref(),
|
||||||
tx, fee, nTime, nHeight, sequence,
|
tx, fee, nTime, nHeight, sequence,
|
||||||
spendsCoinbase, sigOpCost, lp));
|
spendsCoinbase, sigOpCost, lp));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ static void AddTx(const CTransactionRef& tx, const CAmount& nFee, CTxMemPool& po
|
|||||||
bool spendsCoinbase = false;
|
bool spendsCoinbase = false;
|
||||||
unsigned int sigOpCost = 4;
|
unsigned int sigOpCost = 4;
|
||||||
LockPoints lp;
|
LockPoints lp;
|
||||||
AddToMempool(pool, CTxMemPoolEntry(
|
AddToMempool(pool, CTxMemPoolEntry(TxGraph::Ref(),
|
||||||
tx, nFee, nTime, nHeight, sequence,
|
tx, nFee, nTime, nHeight, sequence,
|
||||||
spendsCoinbase, sigOpCost, lp));
|
spendsCoinbase, sigOpCost, lp));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ static void AddTx(const CTransactionRef& tx, CTxMemPool& pool) EXCLUSIVE_LOCKS_R
|
|||||||
bool spendsCoinbase = false;
|
bool spendsCoinbase = false;
|
||||||
unsigned int sigOpCost = 4;
|
unsigned int sigOpCost = 4;
|
||||||
LockPoints lp;
|
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 {
|
struct Available {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
static void AddTx(const CTransactionRef& tx, const CAmount& fee, CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs)
|
static void AddTx(const CTransactionRef& tx, const CAmount& fee, CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs)
|
||||||
{
|
{
|
||||||
LockPoints lp;
|
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)
|
static void RpcMempool(benchmark::Bench& bench)
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ add_library(bitcoinkernel
|
|||||||
../support/lockedpool.cpp
|
../support/lockedpool.cpp
|
||||||
../sync.cpp
|
../sync.cpp
|
||||||
../txdb.cpp
|
../txdb.cpp
|
||||||
|
../txgraph.cpp
|
||||||
../txmempool.cpp
|
../txmempool.cpp
|
||||||
../uint256.cpp
|
../uint256.cpp
|
||||||
../util/chaintype.cpp
|
../util/chaintype.cpp
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include <policy/policy.h>
|
#include <policy/policy.h>
|
||||||
#include <policy/settings.h>
|
#include <policy/settings.h>
|
||||||
#include <primitives/transaction.h>
|
#include <primitives/transaction.h>
|
||||||
|
#include <txgraph.h>
|
||||||
#include <util/epochguard.h>
|
#include <util/epochguard.h>
|
||||||
#include <util/overflow.h>
|
#include <util/overflow.h>
|
||||||
|
|
||||||
@@ -62,7 +63,7 @@ struct CompareIteratorByHash {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class CTxMemPoolEntry
|
class CTxMemPoolEntry : public TxGraph::Ref
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::reference_wrapper<const CTxMemPoolEntry> CTxMemPoolEntryRef;
|
typedef std::reference_wrapper<const CTxMemPoolEntry> CTxMemPoolEntryRef;
|
||||||
@@ -103,11 +104,13 @@ private:
|
|||||||
int64_t nSigOpCostWithAncestors;
|
int64_t nSigOpCostWithAncestors;
|
||||||
|
|
||||||
public:
|
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,
|
int64_t time, unsigned int entry_height, uint64_t entry_sequence,
|
||||||
bool spends_coinbase,
|
bool spends_coinbase,
|
||||||
int64_t sigops_cost, LockPoints lp)
|
int64_t sigops_cost, LockPoints lp)
|
||||||
: tx{tx},
|
: TxGraph::Ref(std::move(ref)),
|
||||||
|
tx{tx},
|
||||||
nFee{fee},
|
nFee{fee},
|
||||||
nTxWeight{GetTransactionWeight(*tx)},
|
nTxWeight{GetTransactionWeight(*tx)},
|
||||||
nUsageSize{RecursiveDynamicUsage(tx)},
|
nUsageSize{RecursiveDynamicUsage(tx)},
|
||||||
|
|||||||
@@ -720,7 +720,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (!m_node.mempool) return {};
|
if (!m_node.mempool) return {};
|
||||||
LockPoints lp;
|
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);
|
LOCK(m_node.mempool->cs);
|
||||||
return m_node.mempool->CheckPackageLimits({tx}, entry.GetTxSize());
|
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 auto entry_height{fuzzed_data_provider.ConsumeIntegralInRange<uint32_t>(0, max_height)};
|
||||||
const bool spends_coinbase = fuzzed_data_provider.ConsumeBool();
|
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);
|
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
|
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,
|
std::optional<std::string> CheckPackageMempoolAcceptResult(const Package& txns,
|
||||||
|
|||||||
+1
-1
@@ -1386,7 +1386,7 @@ CTxMemPool::ChangeSet::TxHandle CTxMemPool::ChangeSet::StageAddition(const CTran
|
|||||||
{
|
{
|
||||||
LOCK(m_pool->cs);
|
LOCK(m_pool->cs);
|
||||||
Assume(m_to_add.find(tx->GetHash()) == m_to_add.end());
|
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};
|
CAmount delta{0};
|
||||||
m_pool->ApplyDelta(tx->GetHash(), delta);
|
m_pool->ApplyDelta(tx->GetHash(), delta);
|
||||||
if (delta) m_to_add.modify(newit, [&delta](CTxMemPoolEntry& e) { e.UpdateModifiedFee(delta); });
|
if (delta) m_to_add.modify(newit, [&delta](CTxMemPoolEntry& e) { e.UpdateModifiedFee(delta); });
|
||||||
|
|||||||
Reference in new issue
Block a user