Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v0 state

Back to all declarations

MaxBody

untyped bigint

MaxBody is the longest note this realm accepts, in bytes. A bound rather than none: every byte stored here locks a storage deposit, paid by whoever signs the write and refunded to whoever signs the delete (EFFECTIVE\_GNO.md section 9.2), and an unbounded write is an unbounded state the realm carries forever.

Value

(280 <untyped> bigint)

MaxTagLen

untyped bigint

MaxTagLen bounds the index key for the same reason, and small because a tag is a label rather than a sentence.

Value

(24 <untyped> bigint)

PageSize

untyped bigint

PageSize is how many tags the root page shows.

Value

(20 <untyped> bigint)

MaxNotes

untyped bigint

MaxNotes and MaxPerAuthor bound the WHOLE board, which MaxBody does not. A per-call length limit bounds one write and nothing else: a caller posting one-byte notes in a loop grows the store and both indexes without limit. "An unbounded container a third party can grow is an unbounded storage deposit someone is paying for" is a rule this realm exists to demonstrate, so it had better obey it. Two caps rather than one, and what each buys is narrower than it looks. MaxNotes bounds the state, which is the property this realm promises. MaxPerAuthor stops one ADDRESS, not one actor: addresses are free, so fifty fresh ones at twenty notes each still fill the board and lock everyone else out until somebody retracts. Keeping a board open to strangers needs something a griefer cannot mint for free, a deposit or an expiry, which this demo does not carry. Retracting frees a slot, so neither cap is a one-way door. MaxPerAuthor is answered by byAuthor.Count, which is the index doing the job it was added for.

Value

(1000 <untyped> bigint)

MaxPerAuthor

untyped bigint

MaxNotes and MaxPerAuthor bound the WHOLE board, which MaxBody does not. A per-call length limit bounds one write and nothing else: a caller posting one-byte notes in a loop grows the store and both indexes without limit. "An unbounded container a third party can grow is an unbounded storage deposit someone is paying for" is a rule this realm exists to demonstrate, so it had better obey it. Two caps rather than one, and what each buys is narrower than it looks. MaxNotes bounds the state, which is the property this realm promises. MaxPerAuthor stops one ADDRESS, not one actor: addresses are free, so fifty fresh ones at twenty notes each still fill the board and lock everyone else out until somebody retracts. Keeping a board open to strangers needs something a griefer cannot mint for free, a deposit or an expiry, which this demo does not carry. Retracting frees a slot, so neither cap is a one-way door. MaxPerAuthor is answered by byAuthor.Count, which is the index doing the job it was added for.

Value

(20 <untyped> bigint)

note

type

Value

v0.note

Post

func(tag string, body string) int64

Post files a note under a tag and returns its id. The store write and both index writes happen here, in this order, in one frame. An abort anywhere in it leaves none of them applied, which is what makes three containers safe to keep apart.

Open
OID
0736c9…fd9a:11
Post details

Inspect func

Retract

func(id int64)

Retract removes a note. Only its author may, and the store and both indexes are unwound together.

Open
OID
0736c9…fd9a:13
Retract details

Inspect func

mustIndex

func(err .uverse.error)
Open
OID
0736c9…fd9a:15
mustIndex details

Inspect func

normaliseTag

func(tag string) string

normaliseTag lowercases and validates the tag. Validated at WRITE time rather than escaped at render time, deliberately: a tag is also an index key and a path segment, so a tag that could carry a pipe or a slash would break the table and the URL as well as the page. The charset is the narrowest thing that still reads as a label.

Open
OID
0736c9…fd9a:16
normaliseTag details

Inspect func

assertRoom

func(who .uverse.address)

assertRoom refuses a write the board has no room for, globally or for this address. Checked before the store write, so a refusal costs the caller the gas of three reads and nothing is half-applied.

Open
OID
0736c9…fd9a:17
assertRoom details

Inspect func

realmURL

untyped string

realmURL is this realm as gnoweb serves it. Links are absolute because the path ends in /v0: a relative "./kitindexdemo:tag/x" resolves against the parent directory to .../kitindexdemo/kitindexdemo:tag/x, which does not exist. Not derived at runtime: a Render has no cur, and CurrentRealm there is the caller. TestRealmURLMatchesTheModule pins it to the module line.

Value

"/r/moul/x/kitindexdemo/v0"

Render

func(path string) string

Render is the whole public surface. Three pages: the tag list, one tag, one author. Every row goes through ui.NewTable rather than concatenated pipes, and every caller string through ui.Cell, because a public path is immutable and a Render that ships wrong ships forever.

Open
OID
0736c9…fd9a:19
Render details

Inspect func

renderIndex

func(req *v0.Request) string
Open
OID
0736c9…fd9a:21
renderIndex details

Inspect func

renderTag

func(tag string) string
Open
OID
0736c9…fd9a:22
renderTag details

Inspect func

renderAuthor

func(addr string) string
Open
OID
0736c9…fd9a:23
renderAuthor details

Inspect func

notesTable

func(hits []v0.ID, empty string) string

notesTable renders a set of ids as rows, skipping any id the store no longer holds. Skipping rather than panicking: an index and a store are two containers, and a reader should see the records that exist rather than a page that aborts. Retract keeps the two in step, so a miss here means a bug worth surviving, not worth hiding.

Open
OID
0736c9…fd9a:24
notesTable details

Inspect func

pager

func(page int, pages int) string

pager renders the previous/next links, or nothing when there is one page.

Open
OID
0736c9…fd9a:25
pager details

Inspect func
MaxBody : untyped bigint =(280 <untyped> bigint)
MaxTagLen : untyped bigint =(24 <untyped> bigint)
PageSize : untyped bigint =(20 <untyped> bigint)
MaxNotes : untyped bigint =(1000 <untyped> bigint)
MaxPerAuthor : untyped bigint =(20 <untyped> bigint)
note : type =v0.note
notes : *v0.Store Inspect
byTag : v0.Index Inspect
byAuthor : v0.Index Inspect
Post : func(tag string, body string) int64 Inspect
Retract : func(id int64) Inspect
caller : func() .uverse.address Inspect
mustIndex : func(err .uverse.error) Inspect
normaliseTag : func(tag string) string Inspect
assertRoom : func(who .uverse.address) Inspect
assertBody : func(body string) Inspect
realmURL : untyped string ="/r/moul/x/kitindexdemo/v0"
Render : func(path string) string Inspect
renderIndex : func(req *v0.Request) string Inspect
renderTag : func(tag string) string Inspect
renderAuthor : func(addr string) string Inspect
notesTable : func(hits []v0.ID, empty string) string Inspect
pager : func(page int, pages int) string Inspect