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 <common/bloom.h>6#include <test/fuzz/FuzzedDataProvider.h>7#include <test/fuzz/fuzz.h>8#include <test/fuzz/util.h>9#include <test/util/random.h>10#include <uint256.h>12#include <cassert>13#include <cstdint>14#include <optional>15#include <string>16#include <vector>18FUZZ_TARGET(rolling_bloom_filter)19{20SeedRandomStateForTest(SeedRand::ZEROS);21FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());23CRollingBloomFilter rolling_bloom_filter{24fuzzed_data_provider.ConsumeIntegralInRange<unsigned int>(1, 1000),250.999 / fuzzed_data_provider.ConsumeIntegralInRange<unsigned int>(1, std::numeric_limits<unsigned int>::max())};26LIMITED_WHILE (fuzzed_data_provider.remaining_bytes() > 0, 3000) {27CallOneOf(28fuzzed_data_provider,29[&] {30const std::vector<unsigned char> b = ConsumeRandomLengthByteVector(fuzzed_data_provider);31(void)rolling_bloom_filter.contains(b);32rolling_bloom_filter.insert(b);33const bool present = rolling_bloom_filter.contains(b);34assert(present);35},36[&] {37const uint256 u256{ConsumeUInt256(fuzzed_data_provider)};38(void)rolling_bloom_filter.contains(u256);39rolling_bloom_filter.insert(u256);40const bool present = rolling_bloom_filter.contains(u256);41assert(present);42},43[&] {44rolling_bloom_filter.reset();45});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.