politeia

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: ISC Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrInsufficientBalance   = "insufficient_balance"
	ErrSyncAlreadyInProgress = "sync_already_in_progress"
	ErrNotExist              = "not_exists"
	ErrInvalid               = "invalid"
	ErrListenerAlreadyExist  = "listener_already_exist"
	ErrInvalidAddress        = "invalid_address"
	ErrInvalidPassphrase     = "invalid_passphrase"
	ErrNoPeers               = "no_peers"
)
View Source
const (
	PoliteiaMainnetHost = "https://proposals.decred.org/api"
	PoliteiaTestnetHost = "http://45.32.108.164:3000/api" // self hosted politeia testnet server

	LastSyncedTimestampConfigKey = "politeia_last_synced_timestamp"
)
View Source
const (
	ProposalCategoryAll int32 = iota + 1
	ProposalCategoryPre
	ProposalCategoryActive
	ProposalCategoryApproved
	ProposalCategoryRejected
	ProposalCategoryAbandoned
)
View Source
const (

	// VoteBitYes is the string value for identifying "yes" vote bits
	VoteBitYes = tkv1.VoteOptionIDApprove
	// VoteBitNo is the string value for identifying "no" vote bits
	VoteBitNo = tkv1.VoteOptionIDReject
)

Variables

This section is empty.

Functions

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using slog.

Types

type EligibleTicket

type EligibleTicket struct {
	Hash    string
	Address string
}

type Politeia

type Politeia struct {
	// contains filtered or unexported fields
}

func New

func New(host string, db *storm.DB) (*Politeia, error)

func (*Politeia) AddSyncCallback added in v1.1.0

func (p *Politeia) AddSyncCallback(syncCallback proposalSyncCallback, uniqueIdentifier string) error

func (*Politeia) CastVotes

func (p *Politeia) CastVotes(ctx context.Context, wallet *wallet.Wallet, eligibleTickets []*ProposalVote, token, passphrase string) error

func (*Politeia) ClearSavedProposals

func (p *Politeia) ClearSavedProposals() error

func (*Politeia) Count

func (p *Politeia) Count(category int32) (int32, error)

Count returns the number of proposals of a specified category

func (*Politeia) FetchProposalDescription

func (p *Politeia) FetchProposalDescription(token string) (string, error)

func (*Politeia) GetLastSyncedTimeStamp

func (p *Politeia) GetLastSyncedTimeStamp() int64

func (*Politeia) GetProposal

func (p *Politeia) GetProposal(censorshipToken string) (string, error)

GetProposal returns the result of GetProposalRaw as a JSON string

func (*Politeia) GetProposalByID

func (p *Politeia) GetProposalByID(proposalID int) (string, error)

GetProposalByID returns the result of GetProposalByIDRaw as a JSON string

func (*Politeia) GetProposalByIDRaw

func (p *Politeia) GetProposalByIDRaw(proposalID int) (*Proposal, error)

GetProposalByIDRaw fetches and returns a single proposal specified by it's ID

func (*Politeia) GetProposalRaw

func (p *Politeia) GetProposalRaw(censorshipToken string) (*Proposal, error)

GetProposalRaw fetches and returns a single proposal specified by it's censorship record token

func (*Politeia) GetProposals

func (p *Politeia) GetProposals(category int32, offset, limit int32, newestFirst bool) (string, error)

GetProposals returns the result of GetProposalsRaw as a JSON string

func (*Politeia) GetProposalsRaw

func (p *Politeia) GetProposalsRaw(category int32, offset, limit int32, newestFirst bool, key string) ([]Proposal, error)

GetProposalsRaw fetches and returns a proposals from the db

func (*Politeia) IsSyncing

func (p *Politeia) IsSyncing() bool

func (*Politeia) Overview

func (p *Politeia) Overview() (*ProposalOverview, error)

func (*Politeia) ProposalVoteDetails

func (p *Politeia) ProposalVoteDetails(ctx context.Context, wallet *wallet.Wallet, token string) (string, error)

func (*Politeia) ProposalVoteDetailsRaw

func (p *Politeia) ProposalVoteDetailsRaw(ctx context.Context, wallet *wallet.Wallet, token string) (*ProposalVoteDetails, error)

func (*Politeia) RemoveSyncCallback added in v1.1.0

func (p *Politeia) RemoveSyncCallback(uniqueIdentifier string)

func (*Politeia) StopSync

func (p *Politeia) StopSync()

func (*Politeia) Sync

func (p *Politeia) Sync(ctx context.Context) error

Sync fetches all proposals from the server and

type Proposal

type Proposal struct {
	ID               int    `storm:"id,increment"`
	Token            string `json:"token" storm:"unique"`
	Category         int32  `json:"category" storm:"index"`
	Name             string `json:"name"`
	State            int32  `json:"state"`
	Status           int32  `json:"status"`
	Timestamp        int64  `json:"timestamp"`
	UserID           string `json:"userid"`
	Username         string `json:"username"`
	NumComments      int32  `json:"numcomments"`
	Version          string `json:"version"`
	PublishedAt      int64  `json:"publishedat"`
	IndexFile        string `json:"indexfile"`
	IndexFileVersion string `json:"fileversion"`
	VoteStatus       int32  `json:"votestatus"`
	VoteApproved     bool   `json:"voteapproved"`
	YesVotes         int32  `json:"yesvotes"`
	NoVotes          int32  `json:"novotes"`
	EligibleTickets  int32  `json:"eligibletickets"`
	QuorumPercentage int32  `json:"quorumpercentage"`
	PassPercentage   int32  `json:"passpercentage"`
	Type             ProposalType
}

type ProposalOverview

type ProposalOverview struct {
	All        int32
	Discussion int32
	Voting     int32
	Approved   int32
	Rejected   int32
	Abandoned  int32
}

type ProposalType added in v1.1.0

type ProposalType int
const (
	ProposalTypeNormal ProposalType = iota
	ProposalTypeRFPProposal
	ProposalTypeRFPSubmission
)

type ProposalVote

type ProposalVote struct {
	Ticket *EligibleTicket
	Bit    string
}

type ProposalVoteDetails

type ProposalVoteDetails struct {
	EligibleTickets []*EligibleTicket
	Votes           []*ProposalVote
	YesVotes        int32
	NoVotes         int32
}

Jump to

Keyboard shortcuts

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