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) 2023-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or https://www.opensource.org/licenses/mit-license.php.5#include <addresstype.h>6#include <bench/bench.h>7#include <blockfilter.h>8#include <chain.h>9#include <index/base.h>10#include <index/blockfilterindex.h>11#include <interfaces/chain.h>12#include <primitives/block.h>13#include <primitives/transaction.h>14#include <pubkey.h>15#include <script/script.h>16#include <sync.h>17#include <test/util/setup_common.h>18#include <test/util/time.h>19#include <uint256.h>20#include <util/check.h>21#include <util/strencodings.h>22#include <util/time.h>23#include <validation.h>25#include <array>26#include <memory>27#include <span>28#include <vector>30using namespace util::hex_literals;32// Very simple block filter index sync benchmark, only using coinbase outputs.33static void BlockFilterIndexSync(benchmark::Bench& bench)34{35const auto test_setup = MakeNoLogFileContext<TestChain100Setup>();37// Create more blocks38int CHAIN_SIZE = 600;39CPubKey pubkey{"02ed26169896db86ced4cbb7b3ecef9859b5952825adbeab998fb5b307e54949c9"_hex_u8};40CScript script = GetScriptForDestination(WitnessV0KeyHash(pubkey));41std::vector<CMutableTransaction> noTxns;42for (int i = 0; i < CHAIN_SIZE - 100; i++) {43test_setup->CreateAndProcessBlock(noTxns, script);44test_setup->m_clock += 1s;45}46assert(WITH_LOCK(::cs_main, return test_setup->m_node.chainman->ActiveHeight() == CHAIN_SIZE));48bench.minEpochIterations(5).run([&] {49BlockFilterIndex filter_index(interfaces::MakeChain(test_setup->m_node), BlockFilterType::BASIC,50/*n_cache_size=*/0, /*f_memory=*/false, /*f_wipe=*/true);51assert(filter_index.Init());52assert(!filter_index.BlockUntilSyncedToCurrentChain());53filter_index.Sync();55IndexSummary summary = filter_index.GetSummary();56assert(summary.synced);57assert(summary.best_block_hash == WITH_LOCK(::cs_main, return test_setup->m_node.chainman->ActiveTip()->GetBlockHash()));59// Shutdown sequence (c.f. Shutdown() in init.cpp)60filter_index.Stop();61});62}64BENCHMARK(BlockFilterIndexSync);
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.