Documentation ¶
Index ¶
- func CheckForUpdates(client *rpcclient.Client) error
- func DisableLog()
- func SetDbPath(path string)
- func UseLogger(logger slog.Logger)
- type AgendaDB
- func (db *AgendaDB) CheckAvailabiltyOfVersionAgendas(version int64) bool
- func (db *AgendaDB) Close() error
- func (db *AgendaDB) ListAgendas() error
- func (db *AgendaDB) LoadAgenda(agendaID string) (*AgendaTagged, error)
- func (db *AgendaDB) StoreAgenda(agenda *AgendaTagged) error
- func (db *AgendaDB) Updatedb(voteVersion int64, client *rpcclient.Client)
- type AgendaTagged
- type ChoiceLabeled
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckForUpdates ¶
CheckForUpdates checks for update at the start of the process and will proceed to update when necessary.
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.
Types ¶
type AgendaDB ¶
AgendaDB represents the data for the saved db
func Open ¶
Open will either open and existing database or create a new one using with the specified file name.
func (*AgendaDB) CheckAvailabiltyOfVersionAgendas ¶
CheckAvailabiltyOfVersionAgendas checks for the availabily of agendas in the saved db by version input
func (*AgendaDB) Close ¶
Close should be called when you are done with the AgendaDB to close the underlying database.
func (*AgendaDB) ListAgendas ¶
ListAgendas lists all agendas stored in the database in order of StartTime.
func (*AgendaDB) LoadAgenda ¶
func (db *AgendaDB) LoadAgenda(agendaID string) (*AgendaTagged, error)
LoadAgenda retrieves an agenda corresponding to the specified unique agenda ID, or nil if it does not exist.
func (*AgendaDB) StoreAgenda ¶
func (db *AgendaDB) StoreAgenda(agenda *AgendaTagged) error
StoreAgenda saves an agenda in the database.
type AgendaTagged ¶
type AgendaTagged struct { Id string `json:"id" storm:"id"` Description string `json:"description"` Mask uint16 `json:"mask"` StartTime uint64 `json:"starttime" storm:"index"` ExpireTime uint64 `json:"expiretime" storm:"index"` Status string `json:"status" storm:"index"` QuorumProgress float64 `json:"quorumprogress" storm:"index"` Choices []dcrjson.Choice `json:"choices"` VoteVersion uint32 `json:"voteversion"` }
AgendaTagged has the same fields as dcrjson.Agenda, but with the Id field marked as the primary key via the `storm:"id"` tag. Fields tagged for indexing by the DB are: StartTime, ExpireTime, Status, and QuorumProgress.
func GetAgendaInfo ¶
func GetAgendaInfo(agendaId string) (*AgendaTagged, error)
GetAgendaInfo fetches an agenda's details given it's agendaId.
func GetAllAgendas ¶
func GetAllAgendas() (agendas []*AgendaTagged, err error)
GetAllAgendas returns all agendas and their info in the db.
func GetVoteAgendasForVersion ¶
func GetVoteAgendasForVersion(ver int64, client *rpcclient.Client) (agendas []AgendaTagged)
GetVoteAgendasForVersion is used in getting the agendas using the vote versions
type ChoiceLabeled ¶
type ChoiceLabeled struct { AgendaChoice [2]string `storm:"id"` AgendaID string `json:"agendaid" storm:"index"` dcrjson.Choice `storm:"inline"` }
ChoiceLabeled embeds dcrjson.Choice along with the AgendaID for the choice, and a string array suitable for use as a primary key. The AgendaID is tagged as an index for quick lookups based on the agenda.