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 state

Back to all declarations

Poll

type

Poll is a single question with its options and per-address vote tracking.

Value

v0.Poll

polls

[]*v0.Poll

// index i holds the poll with ID i

Value

<zero>

nextID

int

Value

0

CreatePoll

func(question string, options string) int

CreatePoll registers a new poll. options is a comma-separated list; blank entries are dropped. Returns the new poll's id. Crossing function: an EOA invokes it via MsgCall; another realm via polls.CreatePoll(cross, q, opts).

Open
OID
00ef1e…2bc8:5
CreatePoll details

Inspect func

Vote

func(pollID int, optionIndex int)

Vote casts one vote for optionIndex on poll pollID. Each caller address may vote at most once per poll. Crossing function.

Open
OID
00ef1e…2bc8:7
Vote details

Inspect func

parseOptions

func(options string) []string

parseOptions splits a comma-separated option string, trimming whitespace and dropping empties. Pure logic — no realm state.

Open
OID
00ef1e…2bc8:8
parseOptions details

Inspect func

getPoll

func(id int) *v0.Poll

getPoll returns the poll with the given id or panics if it does not exist.

Open
OID
00ef1e…2bc8:9
getPoll details

Inspect func

PollCount

func() int

PollCount returns the number of polls created so far (read-only helper).

Open
OID
00ef1e…2bc8:10
PollCount details

Inspect func

barWidth

untyped bigint

Value

(20 <untyped> bigint)

bar

func(count int, total int) string

bar renders a proportional ▓░ bar of fixed width for count out of total.

Open
OID
00ef1e…2bc8:11
bar details

Inspect func

percent

func(count int, total int) int

percent returns the integer percentage of count out of total.

Open
OID
00ef1e…2bc8:12
percent details

Inspect func

total

func(tallies []int) int

total sums a tally slice.

Open
OID
00ef1e…2bc8:13
total details

Inspect func

renderPoll

func(b *strings.Builder, p *v0.Poll)

renderPoll writes one poll's Markdown block into b.

Open
OID
00ef1e…2bc8:14
renderPoll details

Inspect func

Render

func(path string) string

Render produces the Markdown page for gnoweb. It is NOT a crossing function. - "" -> index of all polls - "\<id>" -> a single poll by id

Open
OID
00ef1e…2bc8:15
Render details

Inspect func
Poll : type =v0.Poll
polls : []*v0.Poll =<zero>
nextID : int =0
CreatePoll : func(question string, options string) int Inspect
Vote : func(pollID int, optionIndex int) Inspect
parseOptions : func(options string) []string Inspect
getPoll : func(id int) *v0.Poll Inspect
PollCount : func() int Inspect
barWidth : untyped bigint =(20 <untyped> bigint)
bar : func(count int, total int) string Inspect
percent : func(count int, total int) int Inspect
total : func(tallies []int) int Inspect
renderPoll : func(b *strings.Builder, p *v0.Poll) Inspect
Render : func(path string) string Inspect