Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v0 source realm

Package bloomfilter ports the classic Bloom filter data structure to gno.land: a fixed-size bit array plus k independ...

Readme View source

bloomfilter

⚠️ Experimental — generated with no human supervision. This realm was produced automatically by an MCP-driven agent to exercise the gno MCP server and tooling, and to generate test content for gno compilers, linters and formatters. Not audited. Not for production. Full context & folder README: r/moul/x/daily



Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

🧪 Highly experimental — potentially vibe-coded. Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: DISCLAIMER.

Overview

Package bloomfilter ports the classic Bloom filter data structure to gno.land: a fixed-size bit array plus k independent hash functions that let you test set membership with zero false negatives and a small, bounded false-positive rate — without ever storing the actual items.

Membership is checked via double hashing (Kirsch–Mitzenmacher): two base hashes h1, h2 are combined as h1 + i*h2 to derive k bit positions per item, avoiding the cost of k independent hash functions.

Add is a crossing function per the gno 0.9 interrealm convention (it takes `cur realm` as its first parameter); MightContain and Stats are read-only.

Functions 5

func Add

crossing Action
1func Add(cur realm, item string)
source

Add inserts `item` into the filter. Crossing function: any caller (user or realm) may add, matching this demo's open-membership model.

func FalsePositiveRatePercent

Action
1func FalsePositiveRatePercent() float64
source

FalsePositiveRatePercent estimates the current false-positive rate, in percent, as (bitsSet/m)^k — the standard Bloom filter approximation once bits are randomly distributed. Computed with plain integer/float math to avoid depending on math.Exp/Pow availability.

func MightContain

Action
1func MightContain(item string) bool
source

MightContain reports whether `item` was possibly added before. A false (definitely-not-a-member) answer is always correct; a true answer can occasionally be a false positive, never a false negative.

func Render

1func Render(path string) string
source

Render draws the filter's current stats and recently-added items as Markdown for gnoweb.

func Stats

Action
1func Stats() (int, int, int, int)
source

Stats returns the raw counters backing the Render view and FalsePositiveRatePercent: (itemsAdded, bitsSet, totalBits, hashCount).

Imports 3

  • chain stdlib
  • strconv stdlib
  • strings stdlib

Source Files 3