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

data source realm

Package data keeps GnoRadio's state apart from its rules. It knows nothing of music: ordered collections of string ke...

Overview

Package data keeps GnoRadio's state apart from its rules. It knows nothing of music: ordered collections of string keys to string values, and a vault for the coins of promo budgets (vault.gno).

Each collection belongs to a role, the prefix of its name ("catalog/…"). Only that role's writer realm writes it; anyone reads. A release (new writers for one or more roles) takes over DELAY after every new realm said Ready, all at once, and no data moves. The owner proposes and cancels releases, pauses and resumes roles, passes the role on or renounces it, and can replace the guardian 2x DELAY after saying so. The guardian can only pause and cancel a release. This realm is never replaced: keep it small.

Constants 1

const DELAY

1const DELAY = 72 * 3600
source

DELAY is how long a ready release waits before it takes over. It is a constant so that it can never be shortened.

Functions 35

func Batch

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

Batch applies up to 64 ops of four strings (store.Ops): "set" or "del", collection, key, value. It reads the strings and keeps nothing else of the caller's slice.

func Cancel

crossing Action
1func Cancel(cur realm)
source

Cancel drops the release not yet in force. Owner or guardian. It never touches a guardian replacement.

func Get

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

Get returns the value at key ("" and false when absent).

func GuardianOffer

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

GuardianOffer and GuardianAccept pass the guardian role in two steps; the guardian offers it. The owner's only call on the role is GuardianReplace.

func GuardianRenounce

crossing Action
1func GuardianRenounce(cur realm)
source

GuardianRenounce gives the guardian role up. A replacement the owner already announced still takes over.

func GuardianReplace

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

GuardianReplace is the owner's way out of a lost or stolen guardian key, which could otherwise cancel every release and pause after every resume for good: to becomes the guardian 2x DELAY (six days) later. The guardian cannot cancel it; the owner withdraws it with to = "" or announces another one, which restarts the clock. The wait outlasts a release's DELAY, so a stolen owner key that replaces the guardian is public for six days before its own release can even start its 72 hours. Owner only.

func Index

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

Index is the number of keys before key: Index(c, b) - Index(c, a) counts the keys in [a, b) without a counter. O(log² n).

func IsGnoRadio

Action
1func IsGnoRadio(addr address) bool
source

IsGnoRadio reports whether addr is a GnoRadio realm: this one, the ticket NFT realm, or any current, proposed or past writer.

func Make

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

Make creates a collection under the caller's role (nothing if it exists): "<role>/<name>", name of a-z 0-9 _, at most 32 bytes in all, 32 per role.

func Offer

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

Offer offers the owner role to an address (offering it to the owner cancels the offer); Accept takes it.

func Page

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

Page returns up to limit (1-100) rows with start <= key < end ("" no bound), lowest first or highest first when reverse, as store.Row strings (store.Rows decodes them).

func PageAt

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

PageAt returns up to limit (1-100) rows from the offset-th key, counted from the highest when reverse.

func Pause

crossing Action
1func Pause(cur realm, r string, on bool)
source

Pause stops a role's writes and vault operations at once ("" every role); reads and VaultWithdraw go on. on=false resumes the same writer. The owner pauses and resumes; the guardian only pauses, and only while there is an owner to resume.

func Paused

Action
1func Paused(r string) bool
source

Paused reports whether a role's writes are stopped now.

func Propose

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

Propose adds a role's new writer to the next release. Any change restarts the clock. Owner only.

func Ready

crossing Action
1func Ready(cur realm)
source

Ready is a proposed realm's own call (each rules realm exposes it): once every proposed realm said it, the release takes over DELAY later.

func Remove

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

Remove deletes a key and reports whether it was there.

func Renounce

crossing Action
1func Renounce(cur realm)
source

Renounce gives the owner role up: writers never change again and nothing can be paused. Refused while a role is paused, which could then never write again. It drops the release not yet in force.

func Set

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

Set writes value at key of a collection of the caller's role.

func Size

Action
1func Size(name string) int
source

Size is the number of keys of a collection.

func VaultCredit

crossing Action
1func VaultCredit(cur realm, acct string, funder address, amt int64)
source

VaultCredit adds amt, which the writer has just sent to this realm, to an account funded by funder. A new funder needs an empty account (VaultRefund first).

func VaultDay

Action
1func VaultDay() int64
source

VaultDay is the UTC day of the vault's clock, which stands still while any role is paused: a pause never makes a hold lapse, it lapses that much later. The clock lags real time by every past pause, so a hold made after one also lasts that much longer.

func VaultHeld

Action
1func VaultHeld(acct string, day int64) int64
source

VaultHeld is the live hold of an account lapsing on day.

func VaultHold

crossing Action
1func VaultHold(cur realm, acct string, amt, day int64)
source

VaultHold reserves amt of the free balance until the end of day on the vault's clock (from VaultDay to 31 days from now).

func VaultInfo

Action
1func VaultInfo(acct string) (funder address, balance, free int64)
source

VaultInfo is an account's funder, balance and free part (not held).

func VaultPay

crossing Action
1func VaultPay(cur realm, acct string, to address, amt, day int64)
source

VaultPay pays amt from the live hold lapsing on day to an account outside GnoRadio.

func VaultRefund

crossing Action
1func VaultRefund(cur realm, acct string) int64
source

VaultRefund pays the whole balance back to the funder and drops the holds (the profile changed hands). It returns the amount.

func VaultRelease

crossing Action
1func VaultRelease(cur realm, acct string, amt, day int64) int64
source

VaultRelease gives back up to amt of the hold lapsing on day and returns what it released (less when part of it lapsed or was refunded).

func VaultTotal

Action
1func VaultTotal() int64
source

VaultTotal is every account's balance: what this realm holds for them.

func VaultWithdraw

crossing Action
1func VaultWithdraw(cur realm, acct string)
source

VaultWithdraw pays the caller what is free in an account they funded. It works whoever the writer is, while paused and after Renounce.

func Writer

Action
1func Writer(r string) string
source

Writer is the realm that writes a role's collections now.

func Writers

Action
1func Writers() string
source

Writers is the state of every role, as JSON: {"owner","pendingOwner", "guardian","pendingGuardian","nextGuardian","guardianAt","at","roles": {"catalog":{"writer","paused","proposed","ready"},…}}. at is the unix time a ready release takes over, guardianAt the time nextGuardian (the owner's GuardianReplace) does.

Imports 10

Source Files 3