Pure package detail
commondao
gno.land/p/g12e22uqd4jjvvsk6g95re3a44sxuephd5kkrt7m/commondao
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/g12e22uqd4jjvvsk6g95re3a44sxuephd5kkrt7m/commondao
- Block
- 40959
- Deployed (UTC)
- Transaction
- rbmta+Ywg8WNBE3LCUxuTzlL1ptpmISaLW/1OlUrZYk=
Latest RPC state
Source
package commondao
import (
"gno.land/p/nt/bptree/v0"
"gno.land/p/nt/seqid/v0"
)
// newProposalStorage creates a new proposal storage.
func newProposalStorage() *proposalStorage {
return &proposalStorage{bptree.NewBPTree32()}
}
// proposalStorage stores proposals indexed by ID.
type proposalStorage struct {
storage *bptree.BPTree // string(proposal ID) -> *Proposal
}
// Get returns a proposal or nil when proposal doesn't exist.
func (s proposalStorage) Get(id uint64) *Proposal {
if v := s.storage.Get(makeProposalKey(id)); v != nil {
return v.(*Proposal)
}
return nil
}
// Add adds a proposal to the storage.
func (s *proposalStorage) Add(p *Proposal) {
if p == nil {
return
}
s.storage.Set(makeProposalKey(p.ID()), p)
}
// Remove removes a proposal from the storage.
func (s *proposalStorage) Remove(id uint64) {
s.storage.Remove(makeProposalKey(id))
}
// Size returns the number of proposals that the storage contains.
func (s proposalStorage) Size() int {
return s.storage.Size()
}
// Iterate iterates proposals.
func (s proposalStorage) Iterate(offset, count int, reverse bool, fn func(*Proposal) bool) bool {
cb := func(_ string, v any) bool { return fn(v.(*Proposal)) }
if reverse {
return s.storage.ReverseIterateByOffset(offset, count, cb)
}
return s.storage.IterateByOffset(offset, count, cb)
}
func makeProposalKey(id uint64) string {
return seqid.ID(id).String()
}
The verified vm/qfuncs operation accepts realm paths only.
Pure packages expose source files but do not have Realm Render.