Bitcoin Core
0.21.1
P2P Digital Currency
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
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 <
rpc/blockchain.h
>
7
#include <
txmempool.h
>
8
9
#include <
univalue.h
>
10
11
12
static
void
AddTx
(
const
CTransactionRef
& tx,
const
CAmount
& fee,
CTxMemPool
& pool)
EXCLUSIVE_LOCKS_REQUIRED
(
cs_main
, pool.cs)
13
{
14
LockPoints
lp
;
15
pool.addUnchecked(
CTxMemPoolEntry
(tx, fee,
/* time */
0,
/* height */
1,
/* spendsCoinbase */
false
,
/* sigOpCost */
4, lp));
16
}
17
18
static
void
RpcMempool
(
benchmark::Bench
& bench)
19
{
20
CTxMemPool
pool;
21
LOCK2
(
cs_main
, pool.
cs
);
22
23
for
(
int
i = 0; i < 1000; ++i) {
24
CMutableTransaction
tx =
CMutableTransaction
();
25
tx.
vin
.resize(1);
26
tx.
vin
[0].scriptSig =
CScript
() <<
OP_1
;
27
tx.
vin
[0].scriptWitness.stack.push_back({1});
28
tx.
vout
.resize(1);
29
tx.
vout
[0].scriptPubKey =
CScript
() <<
OP_1
<<
OP_EQUAL
;
30
tx.
vout
[0].nValue = i;
31
const
CTransactionRef
tx_r{
MakeTransactionRef
(tx)};
32
AddTx
(tx_r,
/* fee */
i, pool);
33
}
34
35
bench.
run
([&] {
36
(void)
MempoolToJSON
(pool,
/*verbose*/
true
);
37
});
38
}
39
40
BENCHMARK
(
RpcMempool
);
CTransactionRef
std::shared_ptr< const CTransaction > CTransactionRef
Definition:
transaction.h:395
LockPoints
Definition:
txmempool.h:37
AddTx
static void AddTx(const CTransactionRef &tx, const CAmount &fee, CTxMemPool &pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main
CMutableTransaction::vin
std::vector< CTxIn > vin
Definition:
transaction.h:355
MakeTransactionRef
static CTransactionRef MakeTransactionRef()
Definition:
transaction.h:396
CTxMemPoolEntry
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
Definition:
txmempool.h:78
CAmount
int64_t CAmount
Amount in satoshis (Can be negative)
Definition:
amount.h:12
blockchain.h
LOCK2
#define LOCK2(cs1, cs2)
Definition:
sync.h:231
txmempool.h
ankerl::nanobench::Bench::run
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition:
nanobench.h:1134
univalue.h
OP_1
Definition:
script.h:75
cs_main
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
Definition:
validation.cpp:129
RpcMempool
static void RpcMempool(benchmark::Bench &bench)
Definition:
rpc_mempool.cpp:18
CMutableTransaction::vout
std::vector< CTxOut > vout
Definition:
transaction.h:356
BENCHMARK
BENCHMARK(RpcMempool)
EXCLUSIVE_LOCKS_REQUIRED
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition:
threadsafety.h:49
bench.h
CTxMemPool
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition:
txmempool.h:488
CScript
Serialized script, used inside transaction inputs and outputs.
Definition:
script.h:404
OP_EQUAL
Definition:
script.h:138
CMutableTransaction
A mutable version of CTransaction.
Definition:
transaction.h:353
MempoolToJSON
UniValue MempoolToJSON(const CTxMemPool &pool, bool verbose, bool include_mempool_sequence)
Mempool to JSON.
Definition:
blockchain.cpp:503
ankerl::nanobench::Bench
Main entry point to nanobench's benchmarking facility.
Definition:
nanobench.h:583
CTxMemPool::cs
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it...
Definition:
txmempool.h:576
lp
LockPoints lp
Definition:
mempool_eviction.cpp:17
Generated on Fri Apr 30 2021 13:53:38 for Bitcoin Core by
1.8.8