PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

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/r/moul/x/daily/ringbufferdemo/v0

Realm
Open in gnoweb ↗

Overview

Kind
Realm (renderable)
Name
v0
Namespace
moul / x / daily / ringbufferdemo
Files
3 (README)(gnomod.toml)
Exported functions
1
Module
gno.land/r/moul/x/daily/ringbufferdemo/v0
gno
0.9

Files (3)

  • README.mdmarkdown
  • gnomod.tomltoml
  • ringbufferdemo.gnogno
ringbufferdemo.gnogno
1// Package ringbufferdemo is a small gnoweb demo of the fixed-capacity FIFO2// provided by the [p/moul/x/daily/ringbuffer](/p/moul/x/daily/ringbuffer/v0)3// library: it pushes more entries than the buffer can hold and shows what4// survives, plus what each overflowing push evicted.5//6// It contains no buffer logic of its own. Stateless, so Render is deterministic.7package ringbufferdemo89import (10	"strconv"11	"strings"1213	"gno.land/p/moul/x/daily/ringbuffer/v0"14)1516const capacity = 41718var feed = []string{"alpha", "bravo", "charlie", "delta", "echo", "foxtrot"}1920// Render renders the demo for gnoweb.21func Render(path string) string {22	var b strings.Builder23	b.WriteString("# Ring Buffer\n\n")24	b.WriteString("A fixed-capacity FIFO that overwrites its oldest entry, demoing the ")25	b.WriteString("[`p/moul/x/daily/ringbuffer`](/p/moul/x/daily/ringbuffer/v0) library.\n\n")26	b.WriteString("Capacity **")27	b.WriteString(strconv.Itoa(capacity))28	b.WriteString("**, pushing ")29	b.WriteString(strconv.Itoa(len(feed)))30	b.WriteString(" entries:\n\n")31	b.WriteString("| push | evicted | contents (oldest → newest) |\n|---|---|---|\n")3233	r := ringbuffer.New(capacity)34	for _, v := range feed {35		ev, dropped := r.Push(v)36		b.WriteString("| `")37		b.WriteString(v)38		b.WriteString("` | ")39		if dropped {40			b.WriteString("`" + ev + "`")41		} else {42			b.WriteString("—")43		}44		b.WriteString(" | `")45		b.WriteString(strings.Join(r.Slice(), " "))46		b.WriteString("` |\n")47	}4849	b.WriteString("\n> The buffer never grows: once full, each push costs the oldest entry. ")50	b.WriteString("On chain that bound is the point — an unbounded queue is an unbounded storage bill.\n")51	return b.String()52}53

Functions

  • Render(path string) string

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

Rendered

RenderedRawgnoweb ↗

vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.