Bitcoin Core  0.20.99
P2P Digital Currency
rpc_blockchain.cpp
Go to the documentation of this file.
1 // Copyright (c) 2016-2020 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 
15 {
17  char a = '\0';
18  stream.write(&a, 1); // Prevent compaction
19 
20  CBlock block;
21  stream >> block;
22 
23  CBlockIndex blockindex;
24  const uint256 blockHash = block.GetHash();
25  blockindex.phashBlock = &blockHash;
26  blockindex.nBits = 403014710;
27 
28  bench.run([&] {
29  (void)blockToJSON(block, &blockindex, &blockindex, /*verbose*/ true);
30  });
31 }
32 
Definition: block.h:62
const std::vector< uint8_t > block413567
Definition: data.cpp:11
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:202
void write(const char *pch, size_t nSize)
Definition: streams.h:435
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition: nanobench.h:1134
static void BlockToJsonVerbose(benchmark::Bench &bench)
UniValue blockToJSON(const CBlock &block, const CBlockIndex *tip, const CBlockIndex *blockindex, bool txDetails)
Block description to JSON.
Definition: blockchain.cpp:147
256-bit opaque blob.
Definition: uint256.h:124
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: chain.h:137
static const int PROTOCOL_VERSION
network protocol versioning
Definition: version.h:12
Main entry point to nanobench&#39;s benchmarking facility.
Definition: nanobench.h:583
BENCHMARK(BlockToJsonVerbose)
uint32_t nBits
Definition: chain.h:180
const uint256 * phashBlock
pointer to the hash of the block, if any. Memory is owned by this CBlockIndex
Definition: chain.h:141