Bitcoin ABC
0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
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 <
chainparamsbase.h
>
7
#include <
consensus/amount.h
>
8
#include <
kernel/cs_main.h
>
9
#include <
kernel/mempool_entry.h
>
10
#include <
rpc/mempool.h
>
11
#include <test/util/setup_common.h>
12
#include <
txmempool.h
>
13
14
#include <
univalue.h
>
15
16
static
void
AddTx
(
const
CTransactionRef
&tx,
const
Amount
&fee,
17
CTxMemPool
&pool)
EXCLUSIVE_LOCKS_REQUIRED
(
cs_main
, pool.cs) {
18
LockPoints
lp
;
19
pool.addUnchecked(
CTxMemPoolEntryRef::make
(tx, fee,
/*time=*/
0,
20
/*height=*/
1,
21
/*_sigChecks=*/
1,
lp
));
22
}
23
24
static
void
RpcMempool
(
benchmark::Bench
&
bench
) {
25
const
TestingSetup
test_setup
{
26
CBaseChainParams::MAIN
,
27
/* extra_args */
28
{
29
"-nodebuglogfile"
,
30
"-nodebug"
,
31
},
32
};
33
CTxMemPool
&pool = *
Assert
(
test_setup
.m_node.mempool);
34
LOCK2
(
cs_main
, pool.
cs
);
35
36
for
(
int
i = 0; i < 1000; ++i) {
37
CMutableTransaction
tx =
CMutableTransaction
();
38
tx.
vin
.resize(1);
39
tx.
vin
[0].scriptSig =
CScript
() <<
OP_1
;
40
tx.
vout
.resize(1);
41
tx.
vout
[0].scriptPubKey =
CScript
() <<
OP_1
<<
OP_EQUAL
;
42
tx.
vout
[0].nValue = i *
COIN
;
43
const
CTransactionRef
tx_r
{
MakeTransactionRef
(tx)};
44
AddTx
(
tx_r
,
/* fee */
i *
COIN
, pool);
45
}
46
47
bench
.run([&] { (
void
)
MempoolToJSON
(pool,
/*verbose*/
true
); });
48
}
49
50
BENCHMARK
(
RpcMempool
);
amount.h
COIN
static constexpr Amount COIN
Definition
amount.h:144
bench.h
BENCHMARK
#define BENCHMARK(n)
Definition
bench.h:65
chainparamsbase.h
Assert
#define Assert(val)
Identity function.
Definition
check.h:84
CBaseChainParams::MAIN
static const std::string MAIN
BIP70 chain name strings (main, test or regtest)
Definition
chainparamsbase.h:21
CMutableTransaction
A mutable version of CTransaction.
Definition
transaction.h:274
CMutableTransaction::vout
std::vector< CTxOut > vout
Definition
transaction.h:277
CMutableTransaction::vin
std::vector< CTxIn > vin
Definition
transaction.h:276
CScript
Serialized script, used inside transaction inputs and outputs.
Definition
script.h:431
CTxMemPool
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition
txmempool.h:212
CTxMemPool::cs
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
Definition
txmempool.h:307
RCUPtr::make
static RCUPtr make(Args &&...args)
Construct a new object that is owned by the pointer.
Definition
rcu.h:112
ankerl::nanobench::Bench
Main entry point to nanobench's benchmarking facility.
Definition
nanobench.h:616
cs_main
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition
cs_main.cpp:7
cs_main.h
MempoolToJSON
UniValue MempoolToJSON(const CTxMemPool &pool, bool verbose, bool include_mempool_sequence)
Mempool to JSON.
Definition
mempool.cpp:395
mempool.h
mempool_entry.h
lp
LockPoints lp
Definition
mempool_eviction.cpp:17
MakeTransactionRef
static CTransactionRef MakeTransactionRef()
Definition
transaction.h:316
CTransactionRef
std::shared_ptr< const CTransaction > CTransactionRef
Definition
transaction.h:315
GetRand
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition
random.h:85
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:24
OP_EQUAL
@ OP_EQUAL
Definition
script.h:119
OP_1
@ OP_1
Definition
script.h:56
Amount
Definition
amount.h:19
LockPoints
Definition
mempool_entry.h:22
LOCK2
#define LOCK2(cs1, cs2)
Definition
sync.h:309
EXCLUSIVE_LOCKS_REQUIRED
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition
threadsafety.h:56
txmempool.h
univalue.h
Generated on Sat Nov 23 2024 02:37:58 for Bitcoin ABC by
1.9.8