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.

types.gno

2.09 Kb · 58 lines
 1// Package nsvote holds domain requests and the votes on them.
 2//
 3// A SEPARATE REALM, and deliberately so. It never writes to nsdata: it
 4// only reads it, to answer two questions — does this address hold a
 5// name, and who is the admin. So it needs no trusted-logic grant, it
 6// cannot corrupt the registry however wrong its own logic turns out to
 7// be, and it can be replaced or abandoned without touching a single
 8// name anybody owns.
 9//
10// WHAT IT DOES NOT DO
11//
12// It does not create domains. A vote is advice; creating the domain
13// stays a deliberate admin call in nslogic. Wiring the two together
14// would mean a majority could add a domain nobody had looked at, and
15// the vault has no undo.
16//
17// It holds no funds, at any point, for anybody. The only cost of
18// proposing or voting is the storage each writer pays for their own
19// bytes, which the chain moves directly and which comes back if the
20// record is ever deleted.
21package nsvote
22
23import (
24	"gno.land/p/nt/avl/v0"
25)
26
27// Two things get asked for here, and they are not the same request.
28//
29//	domain  a new *domain to sell names under
30//	chain   a new blockchain to accept an address for on profiles
31//
32// The kind is stored rather than inferred from the label, because
33// "solana" is a plausible request of either sort and guessing wrong
34// files somebody's vote under the wrong question.
35type Proposal struct {
36	kind     string  // "domain" | "chain"
37	label    string  // the domain, or the chain's ticker
38	reason   string  // why, capped: this is storage somebody is paying for
39	proposer address
40	created  int64 // unix seconds
41	yes      int64
42	no       int64
43	status   string // "open" | "accepted" | "rejected" | "withdrawn"
44	decided  int64  // unix seconds, 0 while open
45}
46
47var (
48	proposals avl.Tree // id (zero-padded) -> *Proposal
49	votes     avl.Tree // id + "/" + voter -> "y" | "n"
50	nextID    int64    = 1
51
52	// A reason is a sentence, not an essay. Every character is storage
53	// the proposer pays for and the chain keeps.
54	maxReason = 280
55	// Reading a page walks every name in it, so the ceiling protects the
56	// node rather than the caller.
57	maxPage = 200
58)