agendadb

package
v3.0.0-...-e4f035e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2019 License: ISC Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckForUpdates

func CheckForUpdates(client *rpcclient.Client) error

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.

func SetDbPath

func SetDbPath(path string)

SetDbPath sets the dbPath as fetched from the configuration

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info.

Types

type AgendaDB

type AgendaDB struct {
	NumAgendas int
	NumChoices int
	// contains filtered or unexported fields
}

AgendaDB represents the data for the saved db

func Open

func Open() (*AgendaDB, error)

Open will either open and existing database or create a new one using with the specified file name.

func (*AgendaDB) CheckAvailabiltyOfVersionAgendas

func (db *AgendaDB) CheckAvailabiltyOfVersionAgendas(version int64) bool

CheckAvailabiltyOfVersionAgendas checks for the availabily of agendas in the saved db by version input

func (*AgendaDB) Close

func (db *AgendaDB) Close() error

Close should be called when you are done with the AgendaDB to close the underlying database.

func (*AgendaDB) ListAgendas

func (db *AgendaDB) ListAgendas() error

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.

func (*AgendaDB) Updatedb

func (db *AgendaDB) Updatedb(voteVersion int64, client *rpcclient.Client)

Updatedb used when needed to keep the saved db upto date

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL