mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-25 20:41:21 +02:00
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
This commit is contained in:
@@ -3,7 +3,9 @@
|
|||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include <bench/bench.h>
|
#include <bench/bench.h>
|
||||||
|
#include <chainparamsbase.h>
|
||||||
#include <rpc/mempool.h>
|
#include <rpc/mempool.h>
|
||||||
|
#include <test/util/setup_common.h>
|
||||||
#include <txmempool.h>
|
#include <txmempool.h>
|
||||||
|
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
@@ -17,7 +19,8 @@ static void AddTx(const CTransactionRef& tx, const CAmount& fee, CTxMemPool& poo
|
|||||||
|
|
||||||
static void RpcMempool(benchmark::Bench& bench)
|
static void RpcMempool(benchmark::Bench& bench)
|
||||||
{
|
{
|
||||||
CTxMemPool pool;
|
const auto testing_setup = MakeNoLogFileContext<const ChainTestingSetup>(CBaseChainParams::MAIN);
|
||||||
|
CTxMemPool& pool = *Assert(testing_setup->m_node.mempool);
|
||||||
LOCK2(cs_main, pool.cs);
|
LOCK2(cs_main, pool.cs);
|
||||||
|
|
||||||
for (int i = 0; i < 1000; ++i) {
|
for (int i = 0; i < 1000; ++i) {
|
||||||
|
Reference in New Issue
Block a user