samples
[]stringsamples are valid, canonical encodings, one per type plus the composites.
- OID
- 0d46a5…3d5a:4
samples details
torrent
untyped stringtorrent is the shape the format exists for: a tracker announce beside an info dictionary whose re-encoding is what gets hashed.
Value
"d8:announce21:udp://tracker.example4:infod6:lengthi262144e4:name8:disk.img12:piece lengthi16384eee"
backLink
untyped stringValue
"[back to the demo](/r/moul/x/daily/bencodedemo/v0)\n"
MaxInput
untyped bigintMaxInput 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.
Value
(512 <untyped> bigint)
rejected
[]struct{...}rejected are inputs a sloppy decoder accepts and silently rewrites. Each one would change the digest of whatever contained it.
- OID
- 0d46a5…3d5a:6
rejected details
Render
func(path string) stringRender renders the demo for gnoweb. Render("") / Render("/") -> the types, the round trip, the refusals Render("/<bencoded value>") -> decode that input and show the tree
- OID
- 0d46a5…3d5a:13
Render details
summarize
func(v *v0.Value) stringsummarize describes a value in one cell, without recursing.
- OID
- 0d46a5…3d5a:15
summarize details
tree
func(b *strings.Builder, v *v0.Value, depth int)tree writes a value as a nested markdown list. It takes the builder rather than returning a string: a dictionary of a few hundred entries is reachable inside MaxInput, and += over that many lines copies the page once per line.
- OID
- 0d46a5…3d5a:16
tree details
leaf
func(v *v0.Value) stringleaf renders an int or a string as one line.
- OID
- 0d46a5…3d5a:17
leaf details
parseArg
func(path string) stringparseArg takes the whole render path as the value to decode: a bencoded string contains colons and digits, and splitting on them would mangle it. Only the routing slash comes off. Trimming whitespace would eat a byte the caller declared the length of, so "6:hello " would arrive as a five byte string claiming six and be rejected for the trim rather than for itself.
- OID
- 0d46a5…3d5a:18