MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / BlockFilterIndexSync

Function BlockFilterIndexSync

src/bench/index_blockfilter.cpp:31–60  ·  view source on GitHub ↗

Very simple block filter index sync benchmark, only using coinbase outputs.

Source from the content-addressed store, hash-verified

29
30// Very simple block filter index sync benchmark, only using coinbase outputs.
31static void BlockFilterIndexSync(benchmark::Bench& bench)
32{
33 const auto test_setup = MakeNoLogFileContext<TestChain100Setup>();
34
35 // Create more blocks
36 int CHAIN_SIZE = 600;
37 CPubKey pubkey{"02ed26169896db86ced4cbb7b3ecef9859b5952825adbeab998fb5b307e54949c9"_hex_u8};
38 CScript script = GetScriptForDestination(WitnessV0KeyHash(pubkey));
39 std::vector<CMutableTransaction> noTxns;
40 for (int i = 0; i < CHAIN_SIZE - 100; i++) {
41 test_setup->CreateAndProcessBlock(noTxns, script);
42 test_setup->m_clock += 1s;
43 }
44 assert(WITH_LOCK(::cs_main, return test_setup->m_node.chainman->ActiveHeight() == CHAIN_SIZE));
45
46 bench.minEpochIterations(5).run([&] {
47 BlockFilterIndex filter_index(interfaces::MakeChain(test_setup->m_node), BlockFilterType::BASIC,
48 /*n_cache_size=*/0, /*f_memory=*/false, /*f_wipe=*/true);
49 assert(filter_index.Init());
50 assert(!filter_index.BlockUntilSyncedToCurrentChain());
51 filter_index.Sync();
52
53 IndexSummary summary = filter_index.GetSummary();
54 assert(summary.synced);
55 assert(summary.best_block_hash == WITH_LOCK(::cs_main, return test_setup->m_node.chainman->ActiveTip()->GetBlockHash()));
56
57 // Shutdown sequence (c.f. Shutdown() in init.cpp)
58 filter_index.Stop();
59 });
60}
61
62BENCHMARK(BlockFilterIndexSync);

Callers

nothing calls this directly

Calls 12

GetScriptForDestinationFunction · 0.85
WitnessV0KeyHashClass · 0.85
MakeChainFunction · 0.85
CreateAndProcessBlockMethod · 0.80
minEpochIterationsMethod · 0.80
GetSummaryMethod · 0.80
runMethod · 0.45
InitMethod · 0.45
SyncMethod · 0.45
GetBlockHashMethod · 0.45
StopMethod · 0.45

Tested by

no test coverage detected