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

v1 source realm

Package nsvote holds domain requests and the votes on them.

Overview

Package nsvote holds domain requests and the votes on them.

A SEPARATE REALM, and deliberately so. It never writes to nsdata: it only reads it, to answer two questions — does this address hold a name, and who is the admin. So it needs no trusted-logic grant, it cannot corrupt the registry however wrong its own logic turns out to be, and it can be replaced or abandoned without touching a single name anybody owns.

WHAT IT DOES NOT DO

It does not create domains. A vote is advice; creating the domain stays a deliberate admin call in nslogic. Wiring the two together would mean a majority could add a domain nobody had looked at, and the vault has no undo.

It holds no funds, at any point, for anybody. The only cost of proposing or voting is the storage each writer pays for their own bytes, which the chain moves directly and which comes back if the record is ever deleted.

Functions 12

func CanTakePart

Action
1func CanTakePart(who address) bool
source

CanTakePart answers the one question the page needs before it offers any of this: does this address hold a name.

func HasVoted

Action
1func HasVoted(id int64, voter address) string
source

HasVoted lets the page grey out a button instead of letting somebody sign a transaction that is certain to be rejected.

func ListProposals

Action
1func ListProposals(after string, limit int) (rows, next string)
source

ListProposals pages newest first, which is the order anybody actually wants to read them in.

func Propose

crossing Action
1func Propose(cur realm, kind, label, reason string) int64
source

Propose asks for a domain or for a chain. Anyone holding a name may ask.

The proposer pays the storage for their own proposal, and nothing else. That cost is the whole of the spam control: it is small enough that a real request is nothing to think about and large enough that filling the tree with rubbish is not free.

func Purge

crossing Action
1func Purge(cur realm, id int64) int64
source

Purge deletes a closed request and its votes, releasing the storage.

The refund goes to WHOEVER SIGNS THIS, which is not the people who paid — so it is admin-only and it is not a tidying operation to run casually. It exists because a registry that can only ever grow is worse, not because reclaiming somebody else's deposit is free money.

func Resolve

crossing Action
1func Resolve(cur realm, id int64, accepted bool)
source

Resolve records what was decided. It does NOT create the domain — that stays a separate, deliberate call in nslogic. A vote is advice, and the vault has no undo.

func Roster

Action
1func Roster(after string, limit int) (rows, next string)
source

Roster is the raw material for the leaderboards: one line per name, owner first, so the caller can aggregate however it likes.

It lives here rather than in nslogic because this realm is being deployed anyway and nslogic is not — adding it there would have cost a fresh deployment of the largest realm we have, for a read.

Paged, and the page walks every name in it. That is fine at the scale this registry is at and it will not be fine at fifty thousand names; at that point the aggregate belongs somewhere it is kept as it changes rather than recomputed on every read.

func Version

Action
1func Version() string
source

Version lets a caller find out what it is talking to BEFORE it sends a transaction that would be rejected for having the wrong number of arguments.

v1 has no such function, so a nil answer is itself the answer: an older realm. That is cheaper and more honest than the site assuming the newest shape and failing at signing time, which is exactly what happened when Propose grew a `kind`.

func Vote

crossing Action
1func Vote(cur realm, id int64, yes bool)
source

Vote records a yes or no. One per address per proposal, and it cannot be changed: a vote that can be switched turns the count into a race against whoever is watching, and there is no deadline here to make that fair.

func Withdraw

crossing Action
1func Withdraw(cur realm, id int64)
source

Withdraw closes a request the proposer no longer wants. The votes already cast stay: deleting them would refund their storage to whoever called this, which is not the person who paid it.

Types 1

type Proposal

struct
 1type Proposal struct {
 2	kind     string // "domain" | "chain"
 3	label    string // the domain, or the chain's ticker
 4	reason   string // why, capped: this is storage somebody is paying for
 5	proposer address
 6	created  int64 // unix seconds
 7	yes      int64
 8	no       int64
 9	status   string // "open" | "accepted" | "rejected" | "withdrawn"
10	decided  int64  // unix seconds, 0 while open
11}
source

Two things get asked for here, and they are not the same request.

Example
1domain  a new *domain to sell names under
2chain   a new blockchain to accept an address for on profiles

The kind is stored rather than inferred from the label, because "solana" is a plausible request of either sort and guessing wrong files somebody's vote under the wrong question.

Imports 6

Source Files 4