Bitcoin ABC  0.22.13
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::State &state) {
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  while (state.KeepRunning()) {
30  (void)blockToJSON(block, &blockindex, &blockindex, /*verbose*/ true);
31  }
32 }
33 
const BlockHash * phashBlock
pointer to the hash of the block, if any.
Definition: blockindex.h:27
Definition: block.h:62
const std::vector< uint8_t > block413567
Definition: data.cpp:11
bool KeepRunning()
Definition: bench.h:71
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:196
void write(const char *pch, size_t nSize)
Definition: streams.h:426
BENCHMARK(BlockToJsonVerbose, 10)
static void BlockToJsonVerbose(benchmark::State &state)
UniValue blockToJSON(const CBlock &block, const CBlockIndex *tip, const CBlockIndex *blockindex, bool txDetails)
Block description to JSON.
Definition: blockchain.cpp:145
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: blockindex.h:23
static const int PROTOCOL_VERSION
network protocol versioning
Definition: version.h:11
uint32_t nBits
Definition: blockindex.h:82