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

/p/moul/addrset/v1

Directory · 3 Files
README.md Open

gno.land/p/moul/addrset/v1

A set of blockchain addresses, backed by a B+ tree (gno.land/p/nt/bptree).

The B+ tree successor to p/moul/addrset/v0 (AVL-backed). v1 because the backing data structure — and thus the on-chain storage layout — changed (a compatibility change ⇒ new version). A B+ tree packs many entries per persisted node, so a stored address costs ~0.9 KB vs the AVL backing's ~2.0 KB, and inserts spend materially less gas — prefer v1 for persisted realm state.

1import "gno.land/p/moul/addrset/v1"
2
3var set addrset.Set // zero value is an empty, usable set
4set.Add(addr)       // true (newly added)
5set.Has(addr)       // true
6set.Remove(addr)    // true (was present)
7set.IterateByOffset(0, 10, func(a address) bool { return false })

Differences from v1: the Tree() escape hatch is removed (the backing store never leaks); and — because the B+ tree mutates in place — do not Add/Remove from inside an iteration callback, and do not copy a non-zero Set by value.


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

Dependency graph:

gno.land/p/moul/addrset/v1 dependency graph

Provenance: imported — see https://github.com/moul/gno-contracts/pull/2 for context and metadata.

⚠️ Disclaimer: provided as-is, without warranty; not security-audited. Full disclaimer: DISCLAIMER.