Bitcoin ABC  0.24.7
P2P Digital Currency
rpc_blockchain.cpp
Go to the documentation of this file.
1 // Copyright (c) 2016-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 <bench/data.h>
7 
8 #include <rpc/blockchain.h>
9 #include <streams.h>
10 #include <validation.h>
11 
12 #include <univalue.h>
13 
14 static void BlockToJsonVerbose(benchmark::Bench &bench) {
17  char a = '\0';
18  // Prevent compaction
19  stream.write(&a, 1);
20 
21  CBlock block;
22  stream >> block;
23 
24  CBlockIndex blockindex;
25  const auto blockHash = block.GetHash();
26  blockindex.phashBlock = &blockHash;
27  blockindex.nBits = 403014710;
28 
29  bench.run([&] {
30  (void)blockToJSON(block, &blockindex, &blockindex, /*verbose*/ true);
31  });
32 }
33 
streams.h
CBlockIndex::nBits
uint32_t nBits
Definition: blockindex.h:82
BlockToJsonVerbose
static void BlockToJsonVerbose(benchmark::Bench &bench)
Definition: rpc_blockchain.cpp:14
ankerl::nanobench::Bench
Main entry point to nanobench's benchmarking facility.
Definition: nanobench.h:583
benchmark::data::block413567
const std::vector< uint8_t > block413567
Definition: data.cpp:11
SER_NETWORK
@ SER_NETWORK
Definition: serialize.h:165
CDataStream::write
void write(const char *pch, size_t nSize)
Definition: streams.h:427
univalue.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
BENCHMARK
BENCHMARK(BlockToJsonVerbose)
bench.h
CBlock
Definition: block.h:55
data.h
CDataStream
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:197
blockchain.h
CBlockIndex
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: blockindex.h:23
CBlockIndex::phashBlock
const BlockHash * phashBlock
pointer to the hash of the block, if any.
Definition: blockindex.h:27
blockToJSON
UniValue blockToJSON(const CBlock &block, const CBlockIndex *tip, const CBlockIndex *blockindex, bool txDetails)
Block description to JSON.
Definition: blockchain.cpp:146
PROTOCOL_VERSION
static const int PROTOCOL_VERSION
network protocol versioning
Definition: version.h:11