Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2016-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <bench/bench.h>6#include <bench/data/block413567.raw.h>7#include <consensus/validation.h>8#include <kernel/chainparams.h>9#include <primitives/block.h>10#include <primitives/transaction.h>11#include <serialize.h>12#include <streams.h>13#include <util/check.h>14#include <validation.h>16#include <memory>17#include <span>18#include <vector>20// These are the two major time-sinks which happen after we have fully received21// a block off the wire, but before we can relay the block on to peers using22// compact block relay.24static void DeserializeBlockTest(benchmark::Bench& bench)25{26const auto block_data{benchmark::data::block413567};27bench.unit("block").run([&] {28CBlock block;29SpanReader{block_data} >> TX_WITH_WITNESS(block);30assert(block.vtx.size() == 1557);31});32}34static void CheckBlockTest(benchmark::Bench& bench)35{36const auto& chain_params{CChainParams::Main()};37const auto block_data{benchmark::data::block413567};39CBlock block;40bench.unit("block")41.setup([&] {42block = CBlock{};43SpanReader{block_data} >> TX_WITH_WITNESS(block);44assert(block.vtx.size() == 1557);45})46.run([&] {47BlockValidationState validationState;48const bool checked{CheckBlock(block, validationState, chain_params->GetConsensus())};49assert(checked);50});51}53BENCHMARK(DeserializeBlockTest);54BENCHMARK(CheckBlockTest);
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.