From 020caba3df727ae8ede50eace86ae76971c0fea1 Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Mon, 21 Mar 2022 22:01:51 -0400 Subject: bench: Use existing CTxMemPool in TestingSetup --- src/bench/mempool_eviction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/bench') diff --git a/src/bench/mempool_eviction.cpp b/src/bench/mempool_eviction.cpp index e80b9e1ac2..60d991fab9 100644 --- a/src/bench/mempool_eviction.cpp +++ b/src/bench/mempool_eviction.cpp @@ -108,7 +108,7 @@ static void MempoolEviction(benchmark::Bench& bench) tx7.vout[1].scriptPubKey = CScript() << OP_7 << OP_EQUAL; tx7.vout[1].nValue = 10 * COIN; - CTxMemPool pool; + CTxMemPool& pool = *Assert(testing_setup->m_node.mempool); LOCK2(cs_main, pool.cs); // Create transaction references outside the "hot loop" const CTransactionRef tx1_r{MakeTransactionRef(tx1)}; -- cgit v1.2.3 From d273e53b6e2cabd91a83f0ff0f9b6cfe1815b637 Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Tue, 22 Mar 2022 15:03:13 -0400 Subject: bench/rpc_mempool: Create ChainTestingSetup, use its CTxMemPool This is correct because: - The ChainTestingSetup is constructed before the call to bench.run(...) - All the runs are performed on the same mempool --- src/bench/rpc_mempool.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/bench') diff --git a/src/bench/rpc_mempool.cpp b/src/bench/rpc_mempool.cpp index 6e322ba6aa..0e6fdae3d7 100644 --- a/src/bench/rpc_mempool.cpp +++ b/src/bench/rpc_mempool.cpp @@ -3,7 +3,9 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include +#include #include +#include #include #include @@ -17,7 +19,8 @@ static void AddTx(const CTransactionRef& tx, const CAmount& fee, CTxMemPool& poo static void RpcMempool(benchmark::Bench& bench) { - CTxMemPool pool; + const auto testing_setup = MakeNoLogFileContext(CBaseChainParams::MAIN); + CTxMemPool& pool = *Assert(testing_setup->m_node.mempool); LOCK2(cs_main, pool.cs); for (int i = 0; i < 1000; ++i) { -- cgit v1.2.3