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 pure

Package decisions is the ledger every bridge realm keeps of GovDAO's decisions (bridge/PLAN.md §5.3): a decision is b...

Overview

Package decisions is the ledger every bridge realm keeps of GovDAO's decisions (bridge/PLAN.md §5.3): a decision is born when a proposal made with one of the realm's builders executes, gets the next number, and is either applied at once or queued for 7 days of block time; anyone applies a queued one after its delay, and GovDAO can cancel it in between. The ledger keeps no closure and no proposal text: the parameters a builder wrote are the record. The realm decides what a decision does; this package keeps the numbers, the clocks and the page.

Constants 1

const Day, Factor, Delay, Deadline, PageMax, DAOPath

 1const (
 2	// Day is a day of block time, in seconds.
 3	Day = int64(86400)
 4	// Factor divides every delay of the realms — Delay, Deadline, and the old router's 7 days after a swap, which
 5	// is Delay (§5.9): 1 for the mainnet build, which §8.3's check reads in the served source; the devnet build
 6	// is deployed with 8 here, so its 14 days pass in 42 hours, as the Solana programs' clock-factor-8 feature
 7	// does. A compiled constant beside the launch values, shown on every realm's page. The meters (§5.4) are
 8	// rates per real day and are not divided.
 9	Factor = int64(1)
10	// Delay is the wait a raise, a swap, a credit, a migration or a sweep payment takes after its proposal
11	// executes (§5.3: 7 days by block time), divided by Factor.
12	Delay = 7 * Day / Factor
13	// Deadline is how old a proposal may be when it executes; past it the closure returns an error and GovDAO
14	// marks the proposal denied for good (§5.3: 14 days), divided by Factor.
15	Deadline = 14 * Day / Factor
16	// PageMax is how many decisions of one kind and state the page shows.
17	PageMax = 100
18	// DAOPath is the realm whose frame every builder's closure must be called from, once the governor has yielded
19	// (or from the first block, when none was compiled): the proxy that executes GovDAO's proposals.
20	DAOPath = "gno.land/r/gov/dao"
21)
source

Functions 6

func Clocks

1func Clocks() string
source

Clocks says the clock factor and the delays it gives, for every realm's page: §8.3's check reads it against the served source, where the mainnet build's factor is 1.

func ClocksJSON

1func ClocksJSON() string
source

ClocksJSON is the same for the agents: {"factor":…,"delay":…,"deadline":…}.

func DAOGoverns

1func DAOGoverns(governor address, yielded int64) bool
source

DAOGoverns is whether DAOPath's proxy decides now: no governor was compiled, or the governor yielded at that block height (0 until the yield).

func Expired

1func Expired(made, now int64) error
source

Expired is the one error a builder's closure returns: the proposal was made more than Deadline ago, so GovDAO marks it denied for good. Everything else a closure refuses is a panic, which leaves the proposal for a retry.

func GovernorJSON

1func GovernorJSON(governor address, yielded int64) string
source

GovernorJSON is the same for the agents: `"governor":"…","yielded":H` (no leading or trailing comma).

func GovernorLine

1func GovernorLine(governor address, yielded int64) string
source

GovernorLine is the line every bridge realm's page shows of who governs it.

Types 2

type Decision

struct
 1type Decision struct {
 2	ID        int64
 3	Kind      string // the builder's name, e.g. "set cap floor"
 4	Text      string // the parameters, as the builder wrote them into the proposal's description
 5	Params    any    // the parameters, typed, the realm's own
 6	Made      int64  // unix time the proposal was made (the builder call)
 7	Recorded  int64  // unix time the proposal executed: the decision's birth
 8	Due       int64  // unix time it may be applied: Recorded for an at-once change, Recorded + Delay for a queued one
 9	Applied   int64  // unix time it was applied; 0 while pending
10	Cancelled int64  // unix time GovDAO cancelled it; 0 if it was not
11	Spent     bool   // recorded with no effect (an unpause that would have cleared nothing)
12	Note      string // what happened at execution, in words
13}
source

Decision is one numbered change, as the realm's page shows it.

Methods on Decision

func Pending

method on Decision
1func (d *Decision) Pending() bool
source

Pending is whether the decision still waits to be applied.

func Queued

method on Decision
1func (d *Decision) Queued() bool
source

Queued is whether the decision waits on its delay (pending, and not due at once).

func State

method on Decision
1func (d *Decision) State() string
source

State is "pending", "applied", "cancelled" or "spent".

type Ledger

struct
1type Ledger struct {
2	seq int64
3	all avl.Tree // key(id) → *Decision
4}
source

Ledger numbers and keeps a realm's decisions. The zero value is empty.

Methods on Ledger

func Apply

method on Ledger
1func (l *Ledger) Apply(d *Decision, now int64, note string)
source

Apply marks a decision applied now, with a note.

func Cancel

method on Ledger
1func (l *Ledger) Cancel(id, now int64) (*Decision, error)
source

Cancel marks a pending decision cancelled now. It errors on a number that is not pending.

func Due

method on Ledger
1func (l *Ledger) Due(id, now int64) (*Decision, error)
source

Due is a pending decision whose delay has passed, by number; it errors otherwise.

func Each

method on Ledger
1func (l *Ledger) Each(fn func(d *Decision) bool)
source

Each walks every decision, oldest first, until fn returns true.

func Get

method on Ledger
1func (l *Ledger) Get(id int64) *Decision
source

Get is the decision with this number, or nil.

func JSON

method on Ledger
1func (l *Ledger) JSON() string
source

JSON is every decision, oldest first, as a JSON array.

func Last

method on Ledger
1func (l *Ledger) Last() int64
source

Last is the number of the newest decision (0 if none).

func Page

method on Ledger
1func (l *Ledger) Page() string
source

Page is the decisions page: for every kind, the pending decisions (up to PageMax) and the last PageMax executed ones, newest first.

func Record

method on Ledger
1func (l *Ledger) Record(kind, text string, params any, made, now, due int64) *Decision
source

Record gives a decision the next number and keeps it. due is when it may be applied (now for at once).

func Size

method on Ledger
1func (l *Ledger) Size() int
source

Size is how many decisions were ever recorded.

func Spend

method on Ledger
1func (l *Ledger) Spend(d *Decision, note string)
source

Spend marks a decision spent: recorded, no effect.

Dependencies

Imports 4

/p/g1zdaz6sypk5tdsjc2fzsqrrn4ttn8qzmnl4waqp/decisions/v0

Source Files 2