Pure package detail
daocond
gno.land/p/samcrew/daocond
Indexed deployment identity with independently loaded latest RPC source. Functions and Render are realm-only RPC capabilities.
Indexed deployment
Identity
- Package path
- gno.land/p/samcrew/daocond
- Block
- 98950
- Deployed (UTC)
- Transaction
- AsCc3UJVZUI2dypXfS4QTAJOqzMtdNfDUZlMxFW75sY=
Latest RPC state
Source
package daocond
import (
"gno.land/p/samcrew/avl"
)
type BallotAVL struct {
tree *avl.Tree
}
// Creates a new ballot implementation using AVL tree.
func NewBallot() Ballot {
return &BallotAVL{tree: avl.NewTree()}
}
// Records a vote from a specific voter, overwriting any previous vote.
func (b *BallotAVL) Vote(voter string, vote Vote) {
b.tree.Set(voter, vote)
}
// Gets the vote from a specific voter, returns VoteAbstain if no vote recorded.
func (b *BallotAVL) Get(voter string) Vote {
vote, ok := b.tree.Get(voter)
if !ok {
return VoteAbstain
}
return vote.(Vote)
}
// Returns the total number of votes cast.
func (b *BallotAVL) Total() int {
return b.tree.Size()
}
// Iterates over all votes, calling fn for each voter-vote pair.
func (b *BallotAVL) Iterate(fn func(voter string, vote Vote) bool) {
b.tree.Iterate("", "", func(key string, value interface{}) bool {
v, ok := value.(Vote)
if !ok {
return false
}
return fn(key, v)
})
}
The verified vm/qfuncs operation accepts realm paths only.
Pure packages expose source files but do not have Realm Render.