PathrockNetwork Gno Explorer
HomeBlocksTransactionsRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/p/moul/x/daily/ringbuffer/v0

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
v0
Namespace
moul / x / daily / ringbuffer
Files
3 (README)(gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/moul/x/daily/ringbuffer/v0
gno
0.9

Files (3)

  • README.mdmarkdown
  • gnomod.tomltoml
  • ringbuffer.gnogno
README.mdPreviewRaw
# `gno.land/p/moul/x/daily/ringbuffer/v0`

**Fixed-capacity FIFO that overwrites its oldest entry** — `New`, `Push`, `Pop`,
`Peek`, `At`, `Slice`, `Reset`, `Len`, `Cap`, `Full`, `Empty`, `MaxCap`.

The bounded cousin of a queue, and the bound is the point: on chain an unbounded
queue is an unbounded storage bill, whereas a ring buffer's cost is decided once,
at construction. The right shape for "last N events", "recent messages", or any
rolling window.

```go
import "gno.land/p/moul/x/daily/ringbuffer/v0"

r := ringbuffer.New(3)
r.Push("a"); r.Push("b"); r.Push("c")
evicted, dropped := r.Push("d")   // "a", true
r.Slice()                         // ["b" "c" "d"]
```

`Push` **returns what it evicted**, so a rolling window never loses data
silently — the one thing this shape must not do. Backed by a flat slice with
head/length indices: no per-element allocation, no shifting on `Pop`. `Pop` and
`Reset` clear the vacated slots so no reference is pinned after it is logically
gone.

A zero-capacity buffer stores nothing and says so (`Push` hands the value
straight back), and is never reported as `Full` — a buffer that holds nothing
cannot be full.

**Live demo:** [`r/moul/x/daily/ringbufferdemo`](https://github.com/moul/gno-contracts/tree/main/r/moul/x/daily/ringbufferdemo/v0)
· render it at [`/r/moul/x/daily/ringbufferdemo/v0`](https://gno.land/r/moul/x/daily/ringbufferdemo/v0).

<!-- BEGIN GNOCONTRACTS FOOTER (generated by `make readmes`; do not edit below) -->

---

Part of **[moul/gno-contracts](https://github.com/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](https://github.com/moul/gno-contracts/blob/main/DISCLAIMER.md).

<!-- END GNOCONTRACTS FOOTER -->

Functions

not supported for pure packages by the node (vm/qfuncs)

Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.