dash/src/bench/rpc_mempool.cpp
Kittywhiskers Van Gogh 5261a4733a
refactor: create context for LLMQ subsystem within NodeContext, alias entangled globals (#5030)
* llmq: move initialization logic to 'LLMQContext', add unique pointer to NodeContext

* llmq: add aliases to LLMQ globals, expose them to RPC via LLMQContext

* rpc: replace most global invocations with LLMQContext aliases

* rpc: replace quorum RPC global invocations with LLMQContext aliases

* llmq: replace individual global member arguments with context pointer

* llmq: pass aliased context pointer instead of individual globals in tests

* llmq: move BLS worker to LLMQContext, remove global

* llmq: move DKG debug manager to LLMQContext, remove global

* llmq: move DKG session manager to LLMQContext, remove global

* llmq: move quorum share manager to LLMQContext, remove global

* llmq: move quorum signing manager to LLMQContext, remove global
2022-11-07 21:09:44 +03:00

40 lines
1.2 KiB
C++

// Copyright (c) 2011-2019 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 <bench/bench.h>
#include <rpc/blockchain.h>
#include <txmempool.h>
#include <univalue.h>
static void AddTx(const CTransactionRef& tx, const CAmount& fee, CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs)
{
LockPoints lp;
pool.addUnchecked(CTxMemPoolEntry(tx, fee, /* time */ 0, /* height */ 1, /* spendsCoinbase */ false, /* sigOps */ 1, lp));
}
static void RpcMempool(benchmark::Bench& bench)
{
CTxMemPool pool;
LOCK2(cs_main, pool.cs);
for (int i = 0; i < 1000; ++i) {
CMutableTransaction tx = CMutableTransaction();
tx.vin.resize(1);
tx.vin[0].scriptSig = CScript() << OP_1;
tx.vout.resize(1);
tx.vout[0].scriptPubKey = CScript() << OP_1 << OP_EQUAL;
tx.vout[0].nValue = i;
const CTransactionRef tx_r{MakeTransactionRef(tx)};
AddTx(tx_r, /* fee */ i, pool);
}
bench.minEpochIterations(40).run([&] {
(void)MempoolToJSON(pool, nullptr, /*verbose*/ true);
});
}
BENCHMARK(RpcMempool);