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

store source realm

Package store keeps Gnogolf's data (every record, best, board, standing, round in play and hole) apart from its rules...

Overview

Package store keeps Gnogolf's data (every record, best, board, standing, round in play and hole) apart from its rules, so a new version of the rules takes the data on instead of starting empty. It knows nothing of golf: a few ordered collections of string keys to string values, written only by the one realm it names as its writer (the rules: golf/v2 at the launch), read by anyone. A new writer takes over three days after its code is on chain and says so (the owner proposes it, it calls Ready), on its own; the owner can stop every write at once (Pause), start the same rules again at once (Resume), and renounce the role for good.

Constants 1

const DELAY

1const DELAY = 72 * 3600 // seconds of block time
source

DELAY is how long a proposed writer waits, from its Ready, before it takes over: three days for anyone to read its code on gnoweb, which is on chain from then on and cannot change. A constant: it can never be shortened.

Functions 23

func At

Action
1func At(name string, i int) (string, string)
source

At is the key and value at a place in a collection's order.

func Batch

crossing Action
1func Batch(cur realm, ops []string)
source

Batch applies a save's writes in one call: ops is "set", collection, key, value or "del", collection, key, "" (four strings an op), at most 64 ops. A transaction is all or nothing: a bad op undoes the whole batch.

func Cancel

crossing Action
1func Cancel(cur realm)
source

Cancel drops the proposed writer before it takes over. Only the owner can.

func Get

Action
1func Get(name, key string) (string, bool)
source

Get is a key's value in a collection, and whether it is there.

func Has

Action
1func Has(name, key string) bool
source

Has reports whether a collection holds a key.

func Index

Action
1func Index(name, key string) int
source

Index is how many keys of a collection sort before key: its place, from 0 (O(log n) a step of a binary search, as golf v1's boards).

func Make

crossing Action
1func Make(cur realm, name string)
source

Make adds a collection, for rules that need one more. The writer only.

func Page

Action
1func Page(name, start, end string, limit int) string
source

Page is up to limit keys of a collection from start (included) to end (excluded; "" to its end), in order, as rows one after another: each the key's length, ":", the key, the value's length, ":", the value (no separator to escape: the lengths say where each ends). limit is 1 to 300.

func PageAt

Action
1func PageAt(name string, offset, limit int) string
source

PageAt is up to limit keys from the offset-th of a collection (from 0), as Page's rows.

func PageBack

Action
1func PageBack(name, start, end string, limit int) string
source

PageBack is Page from end (kept, as bptree's back walk) down to start.

func Pause

crossing Action
1func Pause(cur realm)
source

Pause stops every write at once (the reads go on), and drops any proposal. Only the owner can: for a bug in the rules, or one feared. Resume starts the same rules again at once; new rules take their delay.

func Propose

crossing Action
1func Propose(cur realm, pkgpath string)
source

Propose names the next writer, a realm's pkgpath under gno.land/r/. Only the owner can; a new proposal replaces the last. Its delay starts when that realm, on chain, calls Ready: its code can then be read, as it will run.

func Proposed

Action
1func Proposed() (string, int64)
source

Proposed is the writer proposed and when it takes over (unix seconds; 0 while its code has not called Ready), or "" and 0.

func Ready

crossing Action
1func Ready(cur realm)
source

Ready is the proposed writer's own call, once it is on chain: it takes over DELAY later, with no transaction to send. Only that realm can, once.

func Remove

crossing Action
1func Remove(cur realm, name, key string) bool
source

Remove drops a key from a collection, reporting whether it was there. The writer only.

func Render

1func Render(path string) string
source

Render says who writes, what is proposed and who may change it.

func Renounce

crossing Action
1func Renounce(cur realm)
source

Renounce gives the role up for good: the writer can then never change, nor be paused; a proposal not yet in force is dropped. Only the owner can, and not while paused: no rules could ever write again.

func Resume

crossing Action
1func Resume(cur realm)
source

Resume starts again, at once, the rules a Pause stopped: their code was in force already, so nothing new runs. Only the owner can.

func Set

crossing Action
1func Set(cur realm, name, key, value string)
source

Set keeps value under key in a collection. The writer only.

func Size

Action
1func Size(name string) int
source

Size is how many keys a collection holds.

func Transfer

crossing Action
1func Transfer(cur realm, to address)
source

Transfer offers the owner's role, which the address offered takes with Accept.

func Writer

Action
1func Writer() string
source

Writer is the realm whose writes store takes now: the proposed one once its delay is over ("" while paused).

Imports 6

Source Files 2