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

v0 state

Back to all declarations

proposal

type

proposal is one of the fixed choices set up at Init time.

Value

v0.proposal

voterInfo

type

voterInfo tracks one address's voting rights and delegation state.

Value

v0.voterInfo

chairperson

.uverse.address

Package-level persistent state.

Value

<zero>

initialized

bool

Package-level persistent state.

Value

false

proposals

[]v0.proposal

Package-level persistent state.

Value

<zero>

voters

*v0.Tree

// address string -> \*voterInfo

Open
OID
0b732f…2ef1:54
voters details

Inspect pointer

errNotChairperson

*errors.errorString
Open
OID
0b732f…2ef1:14
errNotChairperson details

Inspect pointer

errDelegateNoRight

*errors.errorString
Open
OID
0b732f…2ef1:38
errDelegateNoRight details

Inspect pointer

getOrCreateVoter

func(addr .uverse.address) *v0.voterInfo
Open
OID
0b732f…2ef1:46
getOrCreateVoter details

Inspect func

Init

func(proposalNamesCSV string)

Init configures the ballot exactly once: the caller becomes the chairperson (and is immediately given the right to vote), and proposalNamesCSV — a comma-separated list — seeds the fixed set of proposals. It panics if called twice or with no usable proposal names.

Open
OID
0b732f…2ef1:47
Init details

Inspect func

GiveRightToVote

func(voterAddr string)

GiveRightToVote grants voterAddr a voting weight of 1. Only the chairperson may call this, and only for voters who haven't voted yet.

Open
OID
0b732f…2ef1:48
GiveRightToVote details

Inspect func

Delegate

func(toAddr string)

Delegate hands the caller's voting weight to toAddr. If toAddr has already voted, the weight is added directly to that proposal's tally; otherwise it accumulates on toAddr's own weight, ready to be cast (or delegated further) later. Mirrors Solidity's delegation-chain-following with a loop guard.

Open
OID
0b732f…2ef1:49
Delegate details

Inspect func

Vote

func(proposalIndex int)

Vote casts the caller's full weight for proposals\[proposalIndex].

Open
OID
0b732f…2ef1:50
Vote details

Inspect func

WinningProposal

func() int

WinningProposal returns the index of the proposal with the most accumulated weight, breaking ties in favor of the lowest index.

Open
OID
0b732f…2ef1:51
WinningProposal details

Inspect func

WinnerName

func() string

WinnerName returns the name of the current winning proposal, or "" if the ballot hasn't been initialized.

Open
OID
0b732f…2ef1:52
WinnerName details

Inspect func
proposal : type =v0.proposal
voterInfo : type =v0.voterInfo
chairperson : .uverse.address =<zero>
initialized : bool =false
proposals : []v0.proposal =<zero>
voters : *v0.Tree Inspect
errAlreadyInit : *errors.errorString Inspect
errNotInit : *errors.errorString Inspect
errNotChairperson : *errors.errorString Inspect
errNoProposals : *errors.errorString Inspect
errInvalidAddr : *errors.errorString Inspect
errAlreadyRight : *errors.errorString Inspect
errAlreadyVoted : *errors.errorString Inspect
errNoRight : *errors.errorString Inspect
errSelfDelegate : *errors.errorString Inspect
errDelegateLoop : *errors.errorString Inspect
errDelegateNoRight : *errors.errorString Inspect
errBadProposal : *errors.errorString Inspect
init.18 : func() Inspect
requireInit : func() Inspect
getOrCreateVoter : func(addr .uverse.address) *v0.voterInfo Inspect
Init : func(proposalNamesCSV string) Inspect
GiveRightToVote : func(voterAddr string) Inspect
Delegate : func(toAddr string) Inspect
Vote : func(proposalIndex int) Inspect
WinningProposal : func() int Inspect
WinnerName : func() string Inspect
Render : func(path string) string Inspect