Bitcoin Core  0.19.99
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 <validation.h>
9 #include <streams.h>
10 #include <rpc/blockchain.h>
11 
12 #include <univalue.h>
13 
14 static void BlockToJsonVerbose(benchmark::State& state) {
16  char a = '\0';
17  stream.write(&a, 1); // Prevent compaction
18 
19  CBlock block;
20  stream >> block;
21 
22  CBlockIndex blockindex;
23  const uint256 blockHash = block.GetHash();
24  blockindex.phashBlock = &blockHash;
25  blockindex.nBits = 403014710;
26 
27  while (state.KeepRunning()) {
28  (void)blockToJSON(block, &blockindex, &blockindex, /*verbose*/ true);
29  }
30 }
31 
Definition: block.h:72
const std::vector< uint8_t > block413567
Definition: data.cpp:11
bool KeepRunning()
Definition: bench.h:72
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:201
void write(const char *pch, size_t nSize)
Definition: streams.h:434
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:129
256-bit opaque blob.
Definition: uint256.h:120
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
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