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.

v0 source realm

Package bencodedemo is a small gnoweb demo of the bencode codec provided by the [p/moul/x/daily/bencode](/p/moul/x/da...

Readme View source

Bencode

⚠️ Experimental, generated with no human supervision by the daily pipeline to exercise gno tooling. Not audited. See r/moul/x/daily.


Shows the four bencode types, decodes a small torrent into a tree, and lists the non-canonical inputs the decoder refuses.

/r/moul/x/daily/bencodedemo/v0                 → the types, a torrent, the refusals
/r/moul/x/daily/bencodedemo/v0:d3:cow3:mooe    → decode your own value

Demo of the p/moul/x/daily/bencode library, no codec logic lives here. Stateless, so Render is deterministic.

The whole render path after the colon is taken as the value to decode, not a path segment: a bencoded value is full of colons and digits, and splitting on them would mangle the input before the decoder ever sees it. Caller text is escaped with ui.Inline before it reaches the page. Nothing is trimmed either: a trailing space is part of the string that declared its length, so trimming it would reject a valid value for the trim rather than for itself.

The page refuses an input over 512 bytes, which is tighter than the library's own 8192. A Render runs under the chain's query gas meter and gnoweb does not bound a render argument, so the limit that matters here is what the page can lay out, not what the decoder can parse.

The refusal table is the argument for the library: every input in it parses, and every one of them would change the infohash of the document that contained it.

Built for gno 0.9.


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

On mainnet: deployment status transactions unique callers deployed revision

Dependency graph:

gno.land/r/moul/x/daily/bencodedemo/v0 dependency graph

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

Overview

Package bencodedemo is a small gnoweb demo of the bencode codec provided by the p/moul/x/daily/bencode(/p/moul/x/daily/bencode/v0) library: the four types, the round trip that makes an infohash reproducible, and the non-canonical inputs the decoder refuses instead of tidying up.

It contains no codec logic of its own. Stateless, so Render is deterministic: every figure below is computed from the fixed tables at the top of this file, never from chain state.

Constants 1

const MaxInput

1const MaxInput = 512
source

MaxInput bounds what this page will decode. The library accepts up to bencode.MaxLen bytes, but a Render runs under the chain's query gas meter and gnoweb does not bound a render argument, so the page stops well short of the library's own limit. 512 bytes is more than anyone pastes by hand.

Functions 1

func Render

1func Render(path string) string
source

Render renders the demo for gnoweb.

Example
1Render("") / Render("/")        -> the types, the round trip, the refusals
2Render("/<bencoded value>")     -> decode that input and show the tree

Dependencies

Source Files 5