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) 2020-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 <chainparams.h>6#include <clientversion.h>7#include <flatfile.h>8#include <test/fuzz/FuzzedDataProvider.h>9#include <test/fuzz/fuzz.h>10#include <test/fuzz/util.h>11#include <test/util/setup_common.h>12#include <test/util/time.h>13#include <util/time.h>14#include <validation.h>16#include <cstdint>17#include <vector>19namespace {20const TestingSetup* g_setup;21} // namespace23void initialize_load_external_block_file()24{25static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();26g_setup = testing_setup.get();27}29FUZZ_TARGET(load_external_block_file, .init = initialize_load_external_block_file)30{31FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};32FakeNodeClock clock{ConsumeTime(fuzzed_data_provider)};33FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};34AutoFile fuzzed_block_file{fuzzed_file_provider.open()};35if (fuzzed_block_file.IsNull()) {36return;37}38if (fuzzed_data_provider.ConsumeBool()) {39// Corresponds to the -reindex case (track orphan blocks across files).40FlatFilePos flat_file_pos;41std::multimap<uint256, FlatFilePos> blocks_with_unknown_parent;42g_setup->m_node.chainman->LoadExternalBlockFile(fuzzed_block_file, &flat_file_pos, &blocks_with_unknown_parent);43} else {44// Corresponds to the -loadblock= case (orphan blocks aren't tracked across files).45g_setup->m_node.chainman->LoadExternalBlockFile(fuzzed_block_file);46}47}
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.