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/p/moul/x/daily/ratelimit/v0

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
v0
Namespace
moul / x / daily / ratelimit
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/ratelimit/v0
gno
0.9

Files (3)

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

**Deterministic token-bucket rate limiter** — a port of `golang.org/x/time/rate`
with the wall clock replaced by a caller-supplied monotonic tick (on-chain, the
block height).

A `Limiter` owns a set of per-key token buckets sharing one `rate`/`burst`
config. Each bucket refills at `rate` tokens per tick up to `burst`; the caller
picks what a key is (typically an address) and passes the current tick on every
call. Pure integer/float math over persistent avl state — no chain imports, no
ambient state, fully replayable.

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

l := ratelimit.New(0.5, 5.0)     // 0.5 tokens/tick, capacity 5
l.Allow("g1caller", height)      // consume one token; false if empty
l.AllowN("g1caller", height, 3)  // consume 3 atomically; false if <3
l.Tokens("g1caller", height)     // read-only balance (whole tokens)
```

**Live demo:** [`r/moul/x/daily/ratelimitdemo`](https://github.com/moul/gno-contracts/tree/main/r/moul/x/daily/ratelimitdemo/v0)
· render it at [`/r/moul/x/daily/ratelimitdemo/v0`](https://gno.land/r/moul/x/daily/ratelimitdemo/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.

**Dependency graph:**

![gno.land/p/moul/x/daily/ratelimit/v0 dependency graph](https://raw.githubusercontent.com/moul/gno-contracts/main/_assets/gno.land/p/moul/x/daily/ratelimit/v0/deps.png)

> 🧪 **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.