types

package
v8.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2022 License: ISC Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

ShorterDesc maps the short description to there respective vote status type.

Functions

func VotesStatuses

func VotesStatuses() map[VoteStatusType]string

VotesStatuses returns the ShorterDesc map contents exclusive of Invalid and Doesn't exist statuses.

Types

type AttachmentFile

type AttachmentFile struct {
	Name      string `json:"name"`
	MimeType  string `json:"mime"`
	DigestKey string `json:"digest"`
	Payload   string `json:"payload"`
}

AttachmentFile are files and documents submitted as proposal details. https://github.com/decred/politeia/blob/master/politeiawww/api/www/v1/api.md#file

type CensorshipRecord

type CensorshipRecord struct {
	TokenVal   string `json:"token" storm:"unique"`
	MerkleRoot string `json:"merkle"`
	Signature  string `json:"signature"`
}

CensorshipRecord is an entry that was created when the proposal was submitted. https://github.com/decred/politeia/blob/master/politeiawww/api/www/v1/api.md#censorship-record

type Proposal

type Proposal struct {
	Data *ProposalInfo `json:"proposal"`
}

Proposal defines a proposal payload as returned by RouteProposalDetails route.

type ProposalInfo

type ProposalInfo struct {
	ID              int                `json:"id" storm:"id,increment"`
	Name            string             `json:"name"`
	State           ProposalStateType  `json:"state"`
	Status          ProposalStatusType `json:"status"`
	Timestamp       uint64             `json:"timestamp"`
	UserID          string             `json:"userid"`
	Username        string             `json:"username"`
	PublicKey       string             `json:"publickey"`
	Signature       string             `json:"signature"`
	Version         string             `json:"version"`
	NumComments     int32              `json:"numcomments"`
	StatusChangeMsg string             `json:"statuschangemessage"`
	PublishedDate   uint64             `json:"publishedat" storm:"index"`
	CensoredDate    uint64             `json:"censoredat"`
	AbandonedDate   uint64             `json:"abandonedat"`
	// RefID was added to create an easily readable part of the URL that helps
	// to reference the proposals details page. Storm db ignores entries with
	// duplicate pk but returns "ErrAlreadyExists" error if the field other than
	// the pk has the tag "unique".
	RefID string `storm:"unique"`
	// "unique" tag helps to detect when a single proposal instance wants to be
	// pushed to the db as two different instances instead of one. This bug
	// happened due to edits made to a proposal title thus new RefID was created.
	CensorshipRecord `json:"censorshiprecord" storm:"unique"`
	ProposalVotes    `json:"votes"`
}

ProposalInfo holds the proposal details as document here https://github.com/decred/politeia/blob/master/politeiawww/api/www/v1/api.md#user-proposals. It also holds the votes status details. The ID field is auto incremented by the db. A proposal can now be uniquely identified by the RefID value and the the contents on the CensorShipRecord struct.

func (*ProposalInfo) IsEqual

func (pi *ProposalInfo) IsEqual(b *ProposalInfo) bool

IsEqual compares CensorshipRecord, Name, State, NumComments, StatusChangeMsg, Timestamp, CensoredDate, AbandonedDate, PublishedDate, Token, VoteStatus, TotalVotes and count of VoteResults between the two ProposalsInfo structs passed.

func (*ProposalInfo) Metadata

func (pi *ProposalInfo) Metadata(tip, targetBlockTime int64) *ProposalMetadata

Metadata performs some common manipulations of the ProposalInfo data to prepare figures for display. Many of these manipulations require a tip height and a target block time for the network, so those must be provided as arguments.

type ProposalMetadata

type ProposalMetadata struct {
	// The start height of the vote. The end height is already part of the
	// ProposalInfo struct.
	StartHeight int64
	// Time until start for "Authorized" proposals, Time until done for "Started"
	// proposals.
	SecondsTil     int64
	IsPassing      bool
	Approval       float32
	Rejection      float32
	Yes            int64
	No             int64
	VoteCount      int64
	QuorumCount    int64
	QuorumAchieved bool
	PassPercent    float32
}

ProposalMetadata contains some status-dependent data representations for display purposes.

type ProposalStateType

type ProposalStateType int8

ProposalStateType defines the proposal state entry.

const (
	// InvalidState defines the invalid state proposals.
	InvalidState ProposalStateType = iota

	// UnvettedState defines the unvetted state proposals and includes proposals
	// with a status of:
	//   * PropStatusNotReviewed
	//   * PropStatusUnreviewedChanges
	//   * PropStatusCensored
	UnvettedState

	// VettedState defines the vetted state proposals and includes proposals
	// with a status of:
	//   * PropStatusPublic
	//   * PropStatusAbandoned
	VettedState

	// UnknownState indicates a proposal state that is unrecognized.
	UnknownState
)

func ProposalStateFromStr

func ProposalStateFromStr(val string) ProposalStateType

ProposalStateFromStr converts the string into ProposalStateType value.

func (ProposalStateType) String

func (f ProposalStateType) String() string

type ProposalStatusType

type ProposalStatusType piapi.PropStatusT

ProposalStatusType defines the various proposal statuses available as referenced in https://github.com/decred/politeia/blob/master/politeiawww/api/www/v1/v1.go

func (ProposalStatusType) String

func (p ProposalStatusType) String() string

type ProposalVotes

type ProposalVotes struct {
	Token              string         `json:"token"`
	VoteStatus         VoteStatusType `json:"status"`
	VoteResults        []Results      `json:"optionsresult"`
	TotalVotes         int64          `json:"totalvotes"`
	Endheight          string         `json:"endheight"`
	NumOfEligibleVotes int64          `json:"numofeligiblevotes"`
	QuorumPercentage   uint32         `json:"quorumpercentage"`
	PassPercentage     uint32         `json:"passpercentage"`
}

ProposalVotes defines the proposal status (Vote info for the public proposals). https://github.com/decred/politeia/blob/master/politeiawww/api/www/v1/api.md#proposal-vote-status

type Proposals

type Proposals struct {
	Data []*ProposalInfo `json:"proposals"`
}

Proposals defines an array of proposals payload as returned by RouteAllVetted route.

type Results

type Results struct {
	Option        VoteOption `json:"option"`
	VotesReceived int64      `json:"votesreceived"`
}

Results defines the actual vote count info per the votes choices available.

type VoteOption

type VoteOption struct {
	OptionID    string `json:"id"`
	Description string `json:"description"`
	Bits        int32  `json:"bits"`
}

VoteOption defines the actual high level vote results for the specific agenda.

type VoteStatusType

type VoteStatusType piapi.PropVoteStatusT

VoteStatusType defines the various vote statuses available as referenced in https://github.com/decred/politeia/blob/master/politeiawww/api/www/v1/v1.go

func (VoteStatusType) LongDesc

func (s VoteStatusType) LongDesc() string

LongDesc returns the long vote status description.

func (VoteStatusType) ShortDesc

func (s VoteStatusType) ShortDesc() string

ShortDesc returns the shorter vote status description.

type Votes

type Votes struct {
	Data []ProposalVotes `json:"votesstatus"`
}

Votes defines a slice of VotesStatuses as returned by RouteAllVoteStatus.

Jump to

Keyboard shortcuts

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