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

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

bloomfilter/v0 package

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

Add

func Add(cur realm, item string)
Ask AI Claude ChatGPT

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

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/nym-moultest123/x/daily/bloomfilter/v0" -func "Add" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "onyx-1" -remote "https://rpc.onyx.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.onyx.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/nym-moultest123/x/daily/bloomfilter/v0" -func "Add" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "onyx-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.onyx.testnets.gno.land" call.tx
  

FalsePositiveRatePercent

func FalsePositiveRatePercent() float64
Ask AI Claude ChatGPT

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.

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/nym-moultest123/x/daily/bloomfilter/v0.FalsePositiveRatePercent()"

Result

MightContain

func MightContain(item string) bool
Ask AI Claude ChatGPT

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.

Param

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/nym-moultest123/x/daily/bloomfilter/v0.MightContain()"

Result

Render

func Render(path string) string
Ask AI Claude ChatGPT

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

Param

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/nym-moultest123/x/daily/bloomfilter/v0.Render()"

Result

Stats

func Stats() (int, int, int, int)
Ask AI Claude ChatGPT

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

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/nym-moultest123/x/daily/bloomfilter/v0.Stats()"

Result