Bitcoin ABC
0.26.3
P2P Digital Currency
src
bench
rpc_mempool.cpp
Go to the documentation of this file.
1
// Copyright (c) 2011-2019 The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#include <
bench/bench.h
>
6
#include <
consensus/amount.h
>
7
#include <
rpc/blockchain.h
>
8
#include <
txmempool.h
>
9
10
#include <
univalue.h
>
11
12
static
void
AddTx
(
const
CTransactionRef
&tx,
const
Amount
&fee,
13
CTxMemPool
&pool)
EXCLUSIVE_LOCKS_REQUIRED
(
cs_main
, pool.cs) {
14
LockPoints
lp
;
15
pool.addUnchecked(
CTxMemPoolEntry
(tx, fee,
/* time */
0,
16
/* height */
1,
17
/* spendsCoinbase */
false
,
18
/*_sigChecks=*/
1,
lp
));
19
}
20
21
static
void
RpcMempool
(
benchmark::Bench
&bench) {
22
CTxMemPool
pool;
23
LOCK2
(
cs_main
, pool.
cs
);
24
25
for
(
int
i = 0; i < 1000; ++i) {
26
CMutableTransaction
tx =
CMutableTransaction
();
27
tx.
vin
.resize(1);
28
tx.
vin
[0].scriptSig =
CScript
() <<
OP_1
;
29
tx.
vout
.resize(1);
30
tx.
vout
[0].scriptPubKey =
CScript
() <<
OP_1
<<
OP_EQUAL
;
31
tx.
vout
[0].nValue = i *
COIN
;
32
const
CTransactionRef
tx_r{
MakeTransactionRef
(tx)};
33
AddTx
(tx_r,
/* fee */
i *
COIN
, pool);
34
}
35
36
bench.
run
([&] { (void)
MempoolToJSON
(pool,
/*verbose*/
true
); });
37
}
38
39
BENCHMARK
(
RpcMempool
);
amount.h
COIN
static constexpr Amount COIN
Definition:
amount.h:154
bench.h
MempoolToJSON
UniValue MempoolToJSON(const CTxMemPool &pool, bool verbose, bool include_mempool_sequence)
Mempool to JSON.
Definition:
blockchain.cpp:579
blockchain.h
cs_main
RecursiveMutex cs_main
Global state.
Definition:
validation.cpp:111
CMutableTransaction
A mutable version of CTransaction.
Definition:
transaction.h:278
CMutableTransaction::vout
std::vector< CTxOut > vout
Definition:
transaction.h:281
CMutableTransaction::vin
std::vector< CTxIn > vin
Definition:
transaction.h:280
CScript
Serialized script, used inside transaction inputs and outputs.
Definition:
script.h:431
CTxMemPoolEntry
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
Definition:
txmempool.h:88
CTxMemPool
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition:
txmempool.h:438
CTxMemPool::cs
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
Definition:
txmempool.h:521
ankerl::nanobench::Bench
Main entry point to nanobench's benchmarking facility.
Definition:
nanobench.h:616
ankerl::nanobench::Bench::run
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition:
nanobench.h:1183
lp
LockPoints lp
Definition:
mempool_eviction.cpp:17
MakeTransactionRef
static CTransactionRef MakeTransactionRef()
Definition:
transaction.h:320
CTransactionRef
std::shared_ptr< const CTransaction > CTransactionRef
Definition:
transaction.h:319
AddTx
static void AddTx(const CTransactionRef &tx, const Amount &fee, CTxMemPool &pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main
RpcMempool
static void RpcMempool(benchmark::Bench &bench)
Definition:
rpc_mempool.cpp:21
BENCHMARK
BENCHMARK(RpcMempool)
OP_EQUAL
@ OP_EQUAL
Definition:
script.h:119
OP_1
@ OP_1
Definition:
script.h:56
Amount
Definition:
amount.h:19
LockPoints
Definition:
txmempool.h:45
LOCK2
#define LOCK2(cs1, cs2)
Definition:
sync.h:246
EXCLUSIVE_LOCKS_REQUIRED
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition:
threadsafety.h:56
txmempool.h
univalue.h
Generated on Thu Feb 9 2023 02:37:37 for Bitcoin ABC by
1.9.1