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.
501// are always remembered:502for (int i = 0; i < DATASIZE; i++) {503if (i >= 100)504BOOST_CHECK(rb1.contains(data[i-100]));505rb1.insert(data[i]);506BOOST_CHECK(rb1.contains(data[i]));507}509// Insert 999 more random entries:510for (int i = 0; i < 999; i++) {511std::vector<unsigned char> d = RandomData();512rb1.insert(d);513BOOST_CHECK(rb1.contains(d));514}515// Sanity check to make sure the filter isn't just filling up:516nHits = 0;517for (int i = 0; i < DATASIZE; i++) {518if (rb1.contains(data[i]))519++nHits;520}521// Expect about 5 false positives522BOOST_CHECK_EQUAL(nHits, 3U);524// last-1000-entry, 0.01% false positive:525CRollingBloomFilter rb2(1000, 0.001);526for (int i = 0; i < DATASIZE; i++) {527rb2.insert(data[i]);528}529// ... room for all of them:530for (int i = 0; i < DATASIZE; i++) {531BOOST_CHECK(rb2.contains(data[i]));532}533}535BOOST_AUTO_TEST_SUITE_END()
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.