Documentation ¶
Index ¶
- Constants
- Variables
- func EncodeAuthorizeVote(av AuthorizeVote) ([]byte, error)
- func EncodeAuthorizeVoteReply(avr AuthorizeVoteReply) ([]byte, error)
- func EncodeBallot(b Ballot) ([]byte, error)
- func EncodeBallotReply(br BallotReply) ([]byte, error)
- func EncodeBatchVoteSummary(v BatchVoteSummary) ([]byte, error)
- func EncodeBatchVoteSummaryReply(v BatchVoteSummaryReply) ([]byte, error)
- func EncodeCastVoteReply(cvr CastVoteReply) ([]byte, error)
- func EncodeCensorComment(cc CensorComment) ([]byte, error)
- func EncodeCensorCommentReply(ccr CensorCommentReply) ([]byte, error)
- func EncodeComment(c Comment) ([]byte, error)
- func EncodeCommentLikes(gpcv CommentLikes) ([]byte, error)
- func EncodeCommentLikesReply(clr CommentLikesReply) ([]byte, error)
- func EncodeGetComment(gc GetComment) ([]byte, error)
- func EncodeGetCommentReply(gcr GetCommentReply) ([]byte, error)
- func EncodeGetComments(gc GetComments) ([]byte, error)
- func EncodeGetCommentsReply(gcr GetCommentsReply) ([]byte, error)
- func EncodeGetNumComments(gnc GetNumComments) ([]byte, error)
- func EncodeGetNumCommentsReply(gncr GetNumCommentsReply) ([]byte, error)
- func EncodeGetProposalCommentsLikes(gpcv GetProposalCommentsLikes) ([]byte, error)
- func EncodeGetProposalCommentsLikesReply(gpclr GetProposalCommentsLikesReply) ([]byte, error)
- func EncodeInventory(i Inventory) ([]byte, error)
- func EncodeInventoryReply(ir InventoryReply) ([]byte, error)
- func EncodeLikeComment(lc LikeComment) ([]byte, error)
- func EncodeLikeCommentReply(lcr LikeCommentReply) ([]byte, error)
- func EncodeLinkedFrom(lf LinkedFrom) ([]byte, error)
- func EncodeLinkedFromReply(reply LinkedFromReply) ([]byte, error)
- func EncodeLoadVoteResults(lvr LoadVoteResults) ([]byte, error)
- func EncodeLoadVoteResultsReply(reply LoadVoteResultsReply) ([]byte, error)
- func EncodeNewComment(nc NewComment) ([]byte, error)
- func EncodeNewCommentReply(ncr NewCommentReply) ([]byte, error)
- func EncodeStartVote(sv StartVote) ([]byte, error)
- func EncodeStartVoteReply(v StartVoteReply) ([]byte, error)
- func EncodeStartVoteRunoff(v StartVoteRunoff) ([]byte, error)
- func EncodeStartVoteRunoffReply(v StartVoteRunoffReply) ([]byte, error)
- func EncodeStartVoteV1(v StartVoteV1) ([]byte, error)
- func EncodeStartVoteV2(v StartVoteV2) ([]byte, error)
- func EncodeTokenInventory(i TokenInventory) ([]byte, error)
- func EncodeTokenInventoryReply(itr TokenInventoryReply) ([]byte, error)
- func EncodeVoteDetails(vd VoteDetails) ([]byte, error)
- func EncodeVoteDetailsReply(vdr VoteDetailsReply) ([]byte, error)
- func EncodeVoteResults(v VoteResults) ([]byte, error)
- func EncodeVoteResultsReply(v VoteResultsReply) ([]byte, error)
- func EncodeVoteSummary(v VoteSummary) ([]byte, error)
- func EncodeVoteSummaryReply(v VoteSummaryReply) ([]byte, error)
- func EncodeVoteV1(v VoteV1) ([]byte, error)
- func EncodeVoteV2(v VoteV2) ([]byte, error)
- type AuthorizeVote
- type AuthorizeVoteReply
- type Ballot
- type BallotReply
- type BatchVoteSummary
- type BatchVoteSummaryReply
- type CastVote
- type CastVoteReply
- type CensorComment
- type CensorCommentReply
- type Comment
- type CommentLikes
- type CommentLikesReply
- type ErrorStatusT
- type GetComment
- type GetCommentReply
- type GetComments
- type GetCommentsReply
- type GetNumComments
- type GetNumCommentsReply
- type GetProposalCommentsLikes
- type GetProposalCommentsLikesReply
- type Inventory
- type InventoryReply
- type LikeComment
- type LikeCommentReply
- type LinkedFrom
- type LinkedFromReply
- type LoadVoteResults
- type LoadVoteResultsReply
- type NewComment
- type NewCommentReply
- type StartVote
- type StartVoteReply
- type StartVoteRunoff
- type StartVoteRunoffReply
- type StartVoteTuple
- type StartVoteV1
- type StartVoteV2
- type TokenInventory
- type TokenInventoryReply
- type VoteDetails
- type VoteDetailsReply
- type VoteOption
- type VoteOptionResult
- type VoteResults
- type VoteResultsReply
- type VoteSummary
- type VoteSummaryReply
- type VoteT
- type VoteV1
- type VoteV2
Constants ¶
const ( Version = "1" ID = "decred" CmdAuthorizeVote = "authorizevote" CmdStartVote = "startvote" CmdStartVoteRunoff = "startvoterunoff" CmdVoteDetails = "votedetails" CmdVoteSummary = "votesummary" CmdBatchVoteSummary = "batchvotesummary" CmdLoadVoteResults = "loadvoteresults" CmdBallot = "ballot" CmdBestBlock = "bestblock" CmdNewComment = "newcomment" CmdLikeComment = "likecomment" CmdCensorComment = "censorcomment" CmdGetComment = "getcomment" CmdGetComments = "getcomments" CmdGetNumComments = "getnumcomments" CmdProposalVotes = "proposalvotes" CmdCommentLikes = "commentlikes" CmdProposalCommentsLikes = "proposalcommentslikes" CmdInventory = "inventory" CmdTokenInventory = "tokeninventory" CmdLinkedFrom = "linkedfrom" MDStreamAuthorizeVote = 13 // Vote authorization by proposal author MDStreamVoteBits = 14 // Vote bits and mask MDStreamVoteSnapshot = 15 // Vote tickets and start/end parameters // Vote duration requirements for proposal votes (in blocks) VoteDurationMinMainnet = 2016 VoteDurationMaxMainnet = 4032 VoteDurationMinTestnet = 0 VoteDurationMaxTestnet = 4032 // Authorize vote actions AuthVoteActionAuthorize = "authorize" // Authorize a proposal vote AuthVoteActionRevoke = "revoke" // Revoke a proposal vote authorization // Vote option IDs VoteOptionIDApprove = "yes" VoteOptionIDReject = "no" // Vote types // // VoteTypeStandard is used to indicate a simple approve or reject // proposal vote where the winner is the voting option that has met // the specified pass and quorum requirements. // // VoteTypeRunoff specifies a runoff vote that multiple proposals compete in. // All proposals are voted on like normal, but there can only be one winner // in a runoff vote. The winner is the proposal that meets the quorum // requirement, meets the pass requirement, and that has the most net yes // votes. The winning proposal is considered approved and all other proposals // are considered rejected. If no proposals meet the quorum and pass // requirements then all proposals are considered rejected. // Note: in a runoff vote it is possible for a proposal to meet the quorum // and pass requirements but still be rejected if it does not have the most // net yes votes. VoteTypeInvalid VoteT = 0 VoteTypeStandard VoteT = 1 VoteTypeRunoff VoteT = 2 // Versioning VersionStartVoteV1 = 1 VersionStartVoteV2 = 2 // Error status codes ErrorStatusInvalid ErrorStatusT = 0 ErrorStatusInternalError ErrorStatusT = 1 ErrorStatusProposalNotFound ErrorStatusT = 2 ErrorStatusInvalidVoteBit ErrorStatusT = 3 ErrorStatusVoteHasEnded ErrorStatusT = 4 ErrorStatusDuplicateVote ErrorStatusT = 5 ErrorStatusIneligibleTicket ErrorStatusT = 6 )
Plugin settings, kinda doesn;t go here but for now it is fine
const VersionAuthorizeVote = 1
AuthorizeVote is an MDStream that is used to indicate that a proposal has been finalized and is ready to be voted on. The signature and public key are from the proposal author. The author can revoke a previously sent vote authorization by setting the Action field to revoke.
const VersionStartVote = 2
StartVote instructs the plugin to commence voting on a proposal with the provided vote bits.
const VersionStartVoteReply = 1
StartVoteReply is the reply to StartVote.
Variables ¶
var ( // ErrorStatus converts error status codes to human readable text. ErrorStatus = map[ErrorStatusT]string{ ErrorStatusInvalid: "invalid error status", ErrorStatusInternalError: "internal error", ErrorStatusProposalNotFound: "proposal not found", ErrorStatusInvalidVoteBit: "invalid vote bit", ErrorStatusVoteHasEnded: "vote has ended", ErrorStatusDuplicateVote: "duplicate vote", ErrorStatusIneligibleTicket: "ineligbile ticket", } )
Functions ¶
func EncodeAuthorizeVote ¶
func EncodeAuthorizeVote(av AuthorizeVote) ([]byte, error)
EncodeAuthorizeVote encodes AuthorizeVote into a JSON byte slice.
func EncodeAuthorizeVoteReply ¶
func EncodeAuthorizeVoteReply(avr AuthorizeVoteReply) ([]byte, error)
EncodeAuthorizeVote encodes AuthorizeVoteReply into a JSON byte slice.
func EncodeBallot ¶
EncodeCastVotes encodes CastVotes into a JSON byte slice.
func EncodeBallotReply ¶
func EncodeBallotReply(br BallotReply) ([]byte, error)
EncodeCastVoteReplies encodes CastVotes into a JSON byte slice.
func EncodeBatchVoteSummary ¶
func EncodeBatchVoteSummary(v BatchVoteSummary) ([]byte, error)
EncodeBatchVoteSummary encodes BatchVoteSummary into a JSON byte slice.
func EncodeBatchVoteSummaryReply ¶
func EncodeBatchVoteSummaryReply(v BatchVoteSummaryReply) ([]byte, error)
EncodeBatchVoteSummaryReply encodes BatchVoteSummaryReply into a JSON byte slice.
func EncodeCastVoteReply ¶
func EncodeCastVoteReply(cvr CastVoteReply) ([]byte, error)
EncodeCastVoteReply encodes CastVoteReply into a JSON byte slice.
func EncodeCensorComment ¶
func EncodeCensorComment(cc CensorComment) ([]byte, error)
EncodeCensorComment encodes CensorComment into a JSON byte slice.
func EncodeCensorCommentReply ¶
func EncodeCensorCommentReply(ccr CensorCommentReply) ([]byte, error)
EncodeCensorCommentReply encodes CensorCommentReply into a JSON byte slice.
func EncodeComment ¶
EncodeComment encodes Comment into a JSON byte slice.
func EncodeCommentLikes ¶
func EncodeCommentLikes(gpcv CommentLikes) ([]byte, error)
EncodeCommentLikes encodes CommentLikes into a JSON byte slice.
func EncodeCommentLikesReply ¶
func EncodeCommentLikesReply(clr CommentLikesReply) ([]byte, error)
EncodeCommentLikesReply encodes EncodeCommentLikesReply into a JSON byte slice.
func EncodeGetComment ¶
func EncodeGetComment(gc GetComment) ([]byte, error)
EncodeGetComment encodes a GetComment into a JSON byte slice.
func EncodeGetCommentReply ¶
func EncodeGetCommentReply(gcr GetCommentReply) ([]byte, error)
EncodeGetCommentReply encodes a GetCommentReply into a JSON byte slice.
func EncodeGetComments ¶
func EncodeGetComments(gc GetComments) ([]byte, error)
EncodeGetComments encodes GetCommentsReply into a JSON byte slice.
func EncodeGetCommentsReply ¶
func EncodeGetCommentsReply(gcr GetCommentsReply) ([]byte, error)
EncodeGetCommentsReply encodes GetCommentsReply into a JSON byte slice.
func EncodeGetNumComments ¶
func EncodeGetNumComments(gnc GetNumComments) ([]byte, error)
EncodeGetNumComments encodes GetBatchComments into a JSON byte slice.
func EncodeGetNumCommentsReply ¶
func EncodeGetNumCommentsReply(gncr GetNumCommentsReply) ([]byte, error)
EncodeGetNumCommentsReply encodes GetNumCommentsReply into a JSON byte slice.
func EncodeGetProposalCommentsLikes ¶
func EncodeGetProposalCommentsLikes(gpcv GetProposalCommentsLikes) ([]byte, error)
EncodeGetProposalCommentsLikes encodes GetProposalCommentsLikes into a JSON byte slice.
func EncodeGetProposalCommentsLikesReply ¶
func EncodeGetProposalCommentsLikesReply(gpclr GetProposalCommentsLikesReply) ([]byte, error)
EncodeGetProposalCommentsLikesReply encodes EncodeGetProposalCommentsLikesReply into a JSON byte slice.
func EncodeInventory ¶
EncodeInventory encodes Inventory into a JSON byte slice.
func EncodeInventoryReply ¶
func EncodeInventoryReply(ir InventoryReply) ([]byte, error)
EncodeInventoryReply encodes a InventoryReply into a JSON byte slice.
func EncodeLikeComment ¶
func EncodeLikeComment(lc LikeComment) ([]byte, error)
EncodeLikeComment encodes LikeComment into a JSON byte slice.
func EncodeLikeCommentReply ¶
func EncodeLikeCommentReply(lcr LikeCommentReply) ([]byte, error)
EncodeLikeCommentReply encodes LikeCommentReply into a JSON byte slice.
func EncodeLinkedFrom ¶
func EncodeLinkedFrom(lf LinkedFrom) ([]byte, error)
EncodeLinkedFrom encodes a LinkedFrom into a JSON byte slice.
func EncodeLinkedFromReply ¶
func EncodeLinkedFromReply(reply LinkedFromReply) ([]byte, error)
EncodeLinkedFromReply encodes a LinkedFromReply into a JSON byte slice.
func EncodeLoadVoteResults ¶
func EncodeLoadVoteResults(lvr LoadVoteResults) ([]byte, error)
EncodeLoadVoteResults encodes a LoadVoteResults into a JSON byte slice.
func EncodeLoadVoteResultsReply ¶
func EncodeLoadVoteResultsReply(reply LoadVoteResultsReply) ([]byte, error)
EncodeLoadVoteResultsReply encodes a LoadVoteResultsReply into a JSON byte slice.
func EncodeNewComment ¶
func EncodeNewComment(nc NewComment) ([]byte, error)
EncodeNewComment encodes NewComment into a JSON byte slice.
func EncodeNewCommentReply ¶
func EncodeNewCommentReply(ncr NewCommentReply) ([]byte, error)
EncodeNewCommentReply encodes NewCommentReply into a JSON byte slice.
func EncodeStartVote ¶
EncodeStartVote encodes a StartVote into a JSON byte slice.
func EncodeStartVoteReply ¶
func EncodeStartVoteReply(v StartVoteReply) ([]byte, error)
EncodeStartVoteReply encodes StartVoteReply into a JSON byte slice.
func EncodeStartVoteRunoff ¶
func EncodeStartVoteRunoff(v StartVoteRunoff) ([]byte, error)
EncodeStartVoteRunoffencodes StartVoteRunoffinto a JSON byte slice.
func EncodeStartVoteRunoffReply ¶
func EncodeStartVoteRunoffReply(v StartVoteRunoffReply) ([]byte, error)
EncodeStartVoteRunoffReply encodes StartVoteRunoffReply into a JSON byte slice.
func EncodeStartVoteV1 ¶
func EncodeStartVoteV1(v StartVoteV1) ([]byte, error)
EncodeStartVoteV1 encodes a StartVoteV1 into a JSON byte slice.
func EncodeStartVoteV2 ¶
func EncodeStartVoteV2(v StartVoteV2) ([]byte, error)
EncodeStartVoteV2 encodes a StartVoteV2 into a JSON byte slice.
func EncodeTokenInventory ¶
func EncodeTokenInventory(i TokenInventory) ([]byte, error)
EncodeTokenInventory encodes a TokenInventory into a JSON byte slice.
func EncodeTokenInventoryReply ¶
func EncodeTokenInventoryReply(itr TokenInventoryReply) ([]byte, error)
EncodeTokenInventoryReply encodes a TokenInventoryReply into a JSON byte slice.
func EncodeVoteDetails ¶
func EncodeVoteDetails(vd VoteDetails) ([]byte, error)
EncodeVoteDetails encodes VoteDetails into a JSON byte slice.
func EncodeVoteDetailsReply ¶
func EncodeVoteDetailsReply(vdr VoteDetailsReply) ([]byte, error)
EncodeVoteDetailsReply encodes VoteDetailsReply into a JSON byte slice.
func EncodeVoteResults ¶
func EncodeVoteResults(v VoteResults) ([]byte, error)
EncodeVoteResults encodes VoteResults into a JSON byte slice.
func EncodeVoteResultsReply ¶
func EncodeVoteResultsReply(v VoteResultsReply) ([]byte, error)
EncodeVoteResultsReply encodes VoteResults into a JSON byte slice.
func EncodeVoteSummary ¶
func EncodeVoteSummary(v VoteSummary) ([]byte, error)
EncodeVoteSummary encodes VoteSummary into a JSON byte slice.
func EncodeVoteSummaryReply ¶
func EncodeVoteSummaryReply(v VoteSummaryReply) ([]byte, error)
EncodeVoteSummaryReply encodes VoteSummary into a JSON byte slice.
func EncodeVoteV1 ¶
EncodeVoteV1 encodes VoteV1 into a JSON byte slice.
func EncodeVoteV2 ¶
EncodeVoteV2 encodes a VoteV2 into a JSON byte slice.
Types ¶
type AuthorizeVote ¶
type AuthorizeVote struct { // Generated by decredplugin Version uint `json:"version"` // Version of this structure Receipt string `json:"receipt"` // Server signature of client signature Timestamp int64 `json:"timestamp"` // Received UNIX timestamp // Generated by client Action string `json:"action"` // Authorize or revoke Token string `json:"token"` // Proposal censorship token Signature string `json:"signature"` // Signature of token+version+action PublicKey string `json:"publickey"` // Pubkey used for signature }
func DecodeAuthorizeVote ¶
func DecodeAuthorizeVote(payload []byte) (*AuthorizeVote, error)
DecodeAuthorizeVote decodes a JSON byte slice into an AuthorizeVote.
type AuthorizeVoteReply ¶
type AuthorizeVoteReply struct { Action string `json:"action"` // Authorize or revoke RecordVersion string `json:"recordversion"` // Version of record files Receipt string `json:"receipt"` // Server signature of client signature Timestamp int64 `json:"timestamp"` // Received UNIX timestamp }
AuthorizeVoteReply returns the authorize vote action that was executed and the receipt for the action. The receipt is the server side signature of AuthorizeVote.Signature.
func DecodeAuthorizeVoteReply ¶
func DecodeAuthorizeVoteReply(payload []byte) (*AuthorizeVoteReply, error)
DecodeAuthorizeVoteReply decodes a JSON byte slice into a AuthorizeVoteReply.
type Ballot ¶
type Ballot struct {
Votes []CastVote `json:"votes"`
}
Ballot is a batch of votes that are sent to the server.
func DecodeBallot ¶
DecodeCastVotes decodes a JSON byte slice into a CastVotes.
type BallotReply ¶
type BallotReply struct {
Receipts []CastVoteReply `json:"receipts"`
}
BallotReply is a reply to a batched list of votes.
func DecodeBallotReply ¶
func DecodeBallotReply(payload []byte) (*BallotReply, error)
DecodeBallotReply decodes a JSON byte slice into a CastVotes.
type BatchVoteSummary ¶
type BatchVoteSummary struct { Tokens []string `json:"token"` // Censorship token BestBlock uint64 `json:"bestblock"` // Best block }
BatchVoteSummary requests a summary of a set of proposal votes. This includes certain voting period parameters and a summary of the vote results.
func DecodeBatchVoteSummary ¶
func DecodeBatchVoteSummary(payload []byte) (*BatchVoteSummary, error)
DecodeBatchVoteSummary decodes a JSON byte slice into a BatchVoteSummary.
type BatchVoteSummaryReply ¶
type BatchVoteSummaryReply struct {
Summaries map[string]VoteSummaryReply `json:"summaries"` // Vote summaries
}
BatchVoteSummaryReply is the reply to the VoteSummary command and returns certain voting period parameters as well as a summary of the vote results. Results are returned for all tokens that correspond to a proposal. This includes both unvetted and vetted proposals. Tokens that do no correspond to a proposal are not included in the returned map.
func DecodeBatchVoteSummaryReply ¶
func DecodeBatchVoteSummaryReply(payload []byte) (*BatchVoteSummaryReply, error)
DecodeBatchVoteSummaryReply decodes a JSON byte slice into a BatchVoteSummaryReply.
type CastVote ¶
type CastVote struct { Token string `json:"token"` // Proposal ID Ticket string `json:"ticket"` // Ticket ID VoteBit string `json:"votebit"` // Vote bit that was selected, this is encode in hex Signature string `json:"signature"` // Signature of Token+Ticket+VoteBit }
CastVote is a signed vote.
type CastVoteReply ¶
type CastVoteReply struct { ClientSignature string `json:"clientsignature"` // Signature that was sent in Signature string `json:"signature"` // Signature of the ClientSignature Error string `json:"error"` // Error status message ErrorStatus ErrorStatusT `json:"errorstatus,omitempty"` // Error status code }
CastVoteReply contains the signature or error to a cast vote command. The Error and ErrorStatus fields will only be populated if something went wrong while attempting to cast the vote.
func DecodeCastVoteReply ¶
func DecodeCastVoteReply(payload []byte) (*CastVoteReply, error)
DecodeBallotReply decodes a JSON byte slice into a CastVotes.
type CensorComment ¶
type CensorComment struct { Token string `json:"token"` // Proposal censorship token CommentID string `json:"commentid"` // Comment ID Reason string `json:"reason"` // Reason comment was censored Signature string `json:"signature"` // Client signature of Token+CommentID+Reason PublicKey string `json:"publickey"` // Pubkey used for signature // Generated by decredplugin Receipt string `json:"receipt,omitempty"` // Server signature of client signature Timestamp int64 `json:"timestamp,omitempty"` // Received UNIX timestamp }
CensorComment is a journal entry for a censored comment. The signature and public key are from the admin that censored this comment.
func DecodeCensorComment ¶
func DecodeCensorComment(payload []byte) (*CensorComment, error)
DecodeCensorComment decodes a JSON byte slice into a CensorComment.
type CensorCommentReply ¶
type CensorCommentReply struct {
Receipt string `json:"receipt"` // Server signature of client signature
}
CommentCensorReply returns the receipt for the censoring action. The receipt is the server side signature of CommentCensor.Signature.
func DecodeCensorCommentReply ¶
func DecodeCensorCommentReply(payload []byte) (*CensorCommentReply, error)
DecodeCensorComment decodes a JSON byte slice into a CensorCommentReply.
type Comment ¶
type Comment struct { // Data generated by client Token string `json:"token"` // Censorship token ParentID string `json:"parentid"` // Parent comment ID Comment string `json:"comment"` // Comment Signature string `json:"signature"` // Client Signature of Token+ParentID+Comment PublicKey string `json:"publickey"` // Pubkey used for Signature // Metadata generated by decred plugin CommentID string `json:"commentid"` // Comment ID Receipt string `json:"receipt"` // Server signature of the client Signature Timestamp int64 `json:"timestamp"` // Received UNIX timestamp TotalVotes uint64 `json:"totalvotes"` // Total number of up/down votes ResultVotes int64 `json:"resultvotes"` // Vote score Censored bool `json:"censored"` // Has this comment been censored }
Comment is the structure that describes the full server side content. It includes server side meta-data as well. Note that the receipt is the server side.
func DecodeComment ¶
DecodeComment decodes a JSON byte slice into a Comment
type CommentLikes ¶
type CommentLikes struct { Token string `json:"token"` // Censorship token CommentID string `json:"commentid"` // Comment ID }
CommentLikes is used to retrieve all of the comment likes for a single record comment.
func DecodeCommentLikes ¶
func DecodeCommentLikes(payload []byte) (*CommentLikes, error)
DecodeCommentLikes decodes a JSON byte slice into a CommentLikes.
type CommentLikesReply ¶
type CommentLikesReply struct {
CommentLikes []LikeComment `json:"commentlikes"`
}
CommentLikesReply is the reply to CommentLikes and returns all of the upvote/downvote actions for the specified comment.
func DecodeCommentLikesReply ¶
func DecodeCommentLikesReply(payload []byte) (*CommentLikesReply, error)
DecodeCommentLikesReply decodes a JSON byte slice into a CommentLikesReply.
type ErrorStatusT ¶
type ErrorStatusT int
type GetComment ¶
type GetComment struct { Token string `json:"token"` // Proposal ID CommentID string `json:"commentid,omitempty"` // Comment ID Signature string `json:"signature,omitempty"` // Client signature }
GetComment retrieves a single comment. The comment can be retrieved by either comment ID or by signature.
func DecodeGetComment ¶
func DecodeGetComment(payload []byte) (*GetComment, error)
DecodeGetComment decodes a JSON byte slice into a GetComment.
type GetCommentReply ¶
type GetCommentReply struct {
Comment Comment `json:"comment"` // Comment
}
GetCommentReply returns the provided comment.
func DecodeGetCommentReply ¶
func DecodeGetCommentReply(payload []byte) (*GetCommentReply, error)
DecodeGetCommentReply decodes a JSON byte slice into a GetCommentReply.
type GetComments ¶
type GetComments struct {
Token string `json:"token"` // Proposal ID
}
GetComments retrieve all comments for a given proposal. This call returns the cooked comments; deleted/censored comments are not returned.
func DecodeGetComments ¶
func DecodeGetComments(payload []byte) (*GetComments, error)
DecodeGetComments decodes a JSON byte slice into a GetComments.
type GetCommentsReply ¶
type GetCommentsReply struct {
Comments []Comment `json:"comments"` // Comments
}
GetCommentsReply returns the provided number of comments.
func DecodeGetCommentsReply ¶
func DecodeGetCommentsReply(payload []byte) (*GetCommentsReply, error)
DecodeGetCommentsReply decodes a JSON byte slice into a GetCommentsReply.
type GetNumComments ¶
type GetNumComments struct {
Tokens []string `json:"tokens"` // List of censorship tokens
}
GetNumComments returns a map that contains the number of comments for the provided list of censorship tokens. If a provided token does not corresond to an actual proposal then the token will not be included in the returned map. It is the responsibility of the caller to ensure that results are returned for all of the provided tokens.
func DecodeGetNumComments ¶
func DecodeGetNumComments(payload []byte) (*GetNumComments, error)
DecodeGetNumComments decodes a JSON byte slice into a GetBatchComments.
type GetNumCommentsReply ¶
type GetNumCommentsReply struct {
NumComments map[string]int `json:"numcomments"` // [token]numComments
}
GetNumCommentsReply is the reply to the GetNumComments command.
func DecodeGetNumCommentsReply ¶
func DecodeGetNumCommentsReply(payload []byte) (*GetNumCommentsReply, error)
DecodeGetNumCommentsReply decodes a JSON byte slice into a GetNumCommentsReply.
type GetProposalCommentsLikes ¶
type GetProposalCommentsLikes struct {
Token string `json:"token"` // Censorship token
}
GetProposalCommentsLikes is a command to fetch all vote actions on the comments of a given proposal
func DecodeGetProposalCommentsLikes ¶
func DecodeGetProposalCommentsLikes(payload []byte) (*GetProposalCommentsLikes, error)
DecodeGetProposalCommentsLikes decodes a JSON byte slice into a GetProposalCommentsLikes.
type GetProposalCommentsLikesReply ¶
type GetProposalCommentsLikesReply struct {
CommentsLikes []LikeComment `json:"commentslikes"`
}
GetProposalCommentsLikesReply is a reply with all vote actions for the comments of a given proposal
func DecodeGetProposalCommentsLikesReply ¶
func DecodeGetProposalCommentsLikesReply(payload []byte) (*GetProposalCommentsLikesReply, error)
DecodeGetProposalCommentsLikesReply decodes a JSON byte slice into a GetProposalCommentsLikesReply.
type Inventory ¶
type Inventory struct {
Tokens []string `json:"tokens,omitempty"`
}
Inventory is used to retrieve the decred plugin inventory for all versions of the provided record tokens. If no tokens are provided, the decred plugin inventory for all versions of all records will be returned.
func DecodeInventory ¶
DecodeInventory decodes a JSON byte slice into a Inventory.
type InventoryReply ¶
type InventoryReply struct { Comments []Comment `json:"comments"` // Comments LikeComments []LikeComment `json:"likecomments"` // Like comments AuthorizeVotes []AuthorizeVote `json:"authorizevotes"` // Authorize votes AuthorizeVoteReplies []AuthorizeVoteReply `json:"authorizevotereplies"` // Authorize vote replies StartVoteTuples []StartVoteTuple `json:"startvotetuples"` // Start vote tuples CastVotes []CastVote `json:"castvotes"` // Cast votes }
InventoryReply returns the decred plugin inventory.
func DecodeInventoryReply ¶
func DecodeInventoryReply(payload []byte) (*InventoryReply, error)
DecodeInventoryReply decodes a JSON byte slice into a inventory.
type LikeComment ¶
type LikeComment struct { Token string `json:"token"` // Censorship token CommentID string `json:"commentid"` // Comment ID Action string `json:"action"` // Up or downvote (1, -1) Signature string `json:"signature"` // Client Signature of Token+CommentID+Action PublicKey string `json:"publickey"` // Pubkey used for Signature // Only used on disk Receipt string `json:"receipt,omitempty"` // Signature of Signature Timestamp int64 `json:"timestamp,omitempty"` // Received UNIX timestamp }
LikeComment records an up or down vote from a user on a comment.
func DecodeLikeComment ¶
func DecodeLikeComment(payload []byte) (*LikeComment, error)
DecodeLikeComment decodes a JSON byte slice into a LikeComment.
type LikeCommentReply ¶
type LikeCommentReply struct { Total uint64 `json:"total"` // Total number of up and down votes Result int64 `json:"result"` // Current tally of likes, can be negative Receipt string `json:"receipt"` // Server signature of client signature Error string `json:"error,omitempty"` // Error if something wen't wrong during liking a comment }
LikeCommentReply returns the result of an up or down vote.
func DecodeLikeCommentReply ¶
func DecodeLikeCommentReply(payload []byte) (*LikeCommentReply, error)
DecodeLikeCommentReply decodes a JSON byte slice into a LikeCommentReply.
type LinkedFrom ¶
type LinkedFrom struct {
Tokens []string `json:"tokens"`
}
LinkedFrom returns a map[token][]token that contains the linked from list for each of the given proposal tokens. A linked from list is a list of all the proposals that have linked to a given proposal using the LinkTo field in the ProposalMetadata mdstream. If a token does not correspond to an actual proposal then it will not be included in the returned map.
func DecodeLinkedFrom ¶
func DecodeLinkedFrom(payload []byte) (*LinkedFrom, error)
DecodeLinkedFrom decodes a JSON byte slice into a LinkedFrom.
type LinkedFromReply ¶
LinkedFromReply is the reply to the LinkedFrom command.
func DecodeLinkedFromReply ¶
func DecodeLinkedFromReply(payload []byte) (*LinkedFromReply, error)
DecodeLinkedFromReply decodes a JSON byte slice into a LinkedFrom.
type LoadVoteResults ¶
type LoadVoteResults struct {
BestBlock uint64 `json:"bestblock"` // Best block height
}
LoadVoteResults creates a vote results entry in the cache for any proposals that have finsished voting but have not yet been added to the lazy loaded vote results table.
func DecodeLoadVoteResults ¶
func DecodeLoadVoteResults(payload []byte) (*LoadVoteResults, error)
DecodeLoadVoteResults decodes a JSON byte slice into a LoadVoteResults.
type LoadVoteResultsReply ¶
type LoadVoteResultsReply struct{}
LoadVoteResultsReply is the reply to the LoadVoteResults command.
func DecodeLoadVoteResultsReply ¶
func DecodeLoadVoteResultsReply(payload []byte) (*LoadVoteResultsReply, error)
DecodeLoadVoteResultsReply decodes a JSON byte slice into a LoadVoteResults.
type NewComment ¶
type NewComment struct { Token string `json:"token"` // Censorship token ParentID string `json:"parentid"` // Parent comment ID Comment string `json:"comment"` // Comment Signature string `json:"signature"` // Signature of Token+ParentID+Comment PublicKey string `json:"publickey"` // Pubkey used for Signature }
NewComment sends a comment from a user to a specific proposal. Note that the user is implied by the session.
func DecodeNewComment ¶
func DecodeNewComment(payload []byte) (*NewComment, error)
DecodeNewComment decodes a JSON byte slice into a NewComment
type NewCommentReply ¶
type NewCommentReply struct { CommentID string `json:"commentid"` // Comment ID Receipt string `json:"receipt"` // Server signature of the client Signature Timestamp int64 `json:"timestamp"` // Received UNIX timestamp }
NewCommentReply returns the metadata generated by decred plugin for the new comment.
func DecodeNewCommentReply ¶
func DecodeNewCommentReply(payload []byte) (*NewCommentReply, error)
DecodeNewCommentReply decodes a JSON byte slice into a NewCommentReply.
type StartVote ¶
type StartVote struct { Version uint `json:"version"` // Payload StartVote version Token string `json:"token"` // Proposal token Payload string `json:"payload"` // JSON encoded StartVote }
StartVote contains a JSON encoded StartVote of the specified Version. This struct is never written to disk. It is used to pass around the various StartVote versions.
func DecodeStartVote ¶
DecodeStartVote decodes a JSON byte slice into a StartVote.
type StartVoteReply ¶
type StartVoteReply struct { // decred plugin only data Version uint `json:"version"` // Version of this structure // Shared data StartBlockHeight string `json:"startblockheight"` // Block height StartBlockHash string `json:"startblockhash"` // Block hash EndHeight string `json:"endheight"` // Height of vote end EligibleTickets []string `json:"eligibletickets"` // Valid voting tickets }
func DecodeStartVoteReply ¶
func DecodeStartVoteReply(payload []byte) (*StartVoteReply, error)
DecodeVoteReply decodes a JSON byte slice into a StartVoteReply.
type StartVoteRunoff ¶
type StartVoteRunoff struct { Token string `json:"token"` // Token of RFP proposal AuthorizeVotes []AuthorizeVote `json:"authorizevotes"` // Submission auth votes StartVotes []StartVoteV2 `json:"startvotes"` // Submission start votes }
StartVoteRunoff instructs the plugin to start a runoff vote using the given submissions. Each submission is required to have its own AuthorizeVote and StartVote.
func DecodeStartVoteRunoff ¶
func DecodeStartVoteRunoff(payload []byte) (*StartVoteRunoff, error)
DecodeVotedecodes a JSON byte slice into a StartVoteRunoff.
type StartVoteRunoffReply ¶
type StartVoteRunoffReply struct { AuthorizeVoteReplies map[string]AuthorizeVoteReply `json:"authorizevotereply"` StartVoteReply StartVoteReply `json:"startvotereply"` }
StartVoteRunoffReply is the reply to StartVoteRunoff. The StartVoteReply will be the same for all submissions so only one is returned. The individual AuthorizeVoteReply is returned for each submission where the token is the map key.
func DecodeStartVoteRunoffReply ¶
func DecodeStartVoteRunoffReply(payload []byte) (*StartVoteRunoffReply, error)
DecodeVoteReply decodes a JSON byte slice into a StartVoteRunoffReply.
type StartVoteTuple ¶
type StartVoteTuple struct { StartVote StartVote `json:"startvote"` // Start vote StartVoteReply StartVoteReply `json:"startvotereply"` // Start vote reply }
StartVoteTuple is used to return the StartVote and StartVoteReply for a record. StartVoteReply does not contain any record identifying data so it must be returned with the StartVote in order to know what record it belongs to.
type StartVoteV1 ¶
type StartVoteV1 struct { // decred plugin only data Version uint `json:"version"` // Version of this structure PublicKey string `json:"publickey"` // Key used for signature Vote VoteV1 `json:"vote"` // Vote + options Signature string `json:"signature"` // Signature of token }
StartVoteV1 was formerly used to start a proposal vote, but is not longer accepted. A StartVoteV2 must be used to start a proposal vote.
func DecodeStartVoteV1 ¶
func DecodeStartVoteV1(payload []byte) (*StartVoteV1, error)
DecodeVotedecodes a JSON byte slice into a StartVoteV1.
func (*StartVoteV1) VerifySignature ¶
func (s *StartVoteV1) VerifySignature() error
VerifySignature verifies that the StartVoteV1 signature is correct.
type StartVoteV2 ¶
type StartVoteV2 struct { // decred plugin only data Version uint `json:"version"` // Version of this structure PublicKey string `json:"publickey"` // Key used for signature Vote VoteV2 `json:"vote"` // Vote options and params Signature string `json:"signature"` // Signature of Vote hash }
StartVoteV2 is used to start a proposal vote.
The message being signed is the SHA256 digest of the VoteV2 JSON byte slice.
Differences between StartVoteV1 and StartVoteV2:
- Signature is the signature of a hash of the Vote struct. It was previously the signature of just the proposal token.
- Vote is now a VoteV2. See the VoteV2 comment for more details.
func DecodeStartVoteV2 ¶
func DecodeStartVoteV2(payload []byte) (*StartVoteV2, error)
DecodeVotedecodes a JSON byte slice into a StartVoteV2.
func (*StartVoteV2) VerifySignature ¶
func (s *StartVoteV2) VerifySignature() error
VerifySignature verifies that the StartVoteV2 signature is correct.
type TokenInventory ¶
type TokenInventory struct { BestBlock uint64 `json:"bestblock"` // Best block Unvetted bool `json:"unvetted"` // Include unvetted records }
TokenInventory requests the tokens of the records in the inventory, categorized by stage of the voting process. By default, only vetted records are returned.
func DecodeTokenInventory ¶
func DecodeTokenInventory(payload []byte) (*TokenInventory, error)
DecodeTokenInventory decodes a JSON byte slice into a TokenInventory.
type TokenInventoryReply ¶
type TokenInventoryReply struct { // Vetted Records Pre []string `json:"pre"` // Tokens of records that are pre-vote Active []string `json:"active"` // Tokens of records with an active voting period Approved []string `json:"approved"` // Tokens of records that have been approved by a vote Rejected []string `json:"rejected"` // Tokens of records that have been rejected by a vote Abandoned []string `json:"abandoned"` // Tokens of records that have been abandoned // Unvetted records Unreviewed []string `json:"unreviewied"` // Tokens of records that are unreviewed Censored []string `json:"censored"` // Tokens of records that have been censored }
TokenInventoryReply is the response to the TokenInventory command and returns the tokens of all records in the inventory. The tokens are categorized by stage of the voting process and are sorted according to the following rule.
Sorted by record timestamp in descending order: Pre, Abandonded, Unreviewed, Censored
Sorted by voting period end block height in descending order: Active, Approved, Rejected
func DecodeTokenInventoryReply ¶
func DecodeTokenInventoryReply(payload []byte) (*TokenInventoryReply, error)
DecodeTokenInventoryReply decodes a JSON byte slice into a inventory.
type VoteDetails ¶
type VoteDetails struct {
Token string `json:"token"` // Censorship token
}
VoteDetails is used to retrieve the voting period details for a record.
func DecodeVoteDetails ¶
func DecodeVoteDetails(payload []byte) (*VoteDetails, error)
DecodeVoteDetails decodes a JSON byte slice into a VoteDetails.
type VoteDetailsReply ¶
type VoteDetailsReply struct { AuthorizeVote AuthorizeVote `json:"authorizevote"` // Vote authorization StartVote StartVote `json:"startvote"` // Vote ballot StartVoteReply StartVoteReply `json:"startvotereply"` // Start vote snapshot }
VoteDetailsReply is the reply to VoteDetails.
func DecodeVoteDetailsReply ¶
func DecodeVoteDetailsReply(payload []byte) (*VoteDetailsReply, error)
DecodeVoteReply decodes a JSON byte slice into a VoteDetailsReply.
type VoteOption ¶
type VoteOption struct { Id string `json:"id"` // Single unique word identifying vote (e.g. yes) Description string `json:"description"` // Longer description of the vote Bits uint64 `json:"bits"` // Bits used for this option }
VoteOption describes a single vote option.
type VoteOptionResult ¶
type VoteOptionResult struct { ID string `json:"id"` // Single unique word identifying vote (e.g. yes) Description string `json:"description"` // Longer description of the vote. Bits uint64 `json:"bits"` // Bits used for this option Votes uint64 `json:"votes"` // Number of votes cast for this option }
VoteOptionResult describes a vote option and the total number of votes that have been cast for this option.
type VoteResults ¶
type VoteResults struct {
Token string `json:"token"` // Censorship token
}
func DecodeVoteResults ¶
func DecodeVoteResults(payload []byte) (*VoteResults, error)
DecodeVoteResults decodes a JSON byte slice into a VoteResults.
type VoteResultsReply ¶
type VoteResultsReply struct {
CastVotes []CastVote `json:"castvotes"` // All votes
}
func DecodeVoteResultsReply ¶
func DecodeVoteResultsReply(payload []byte) (*VoteResultsReply, error)
DecodeVoteResultsReply decodes a JSON byte slice into a VoteResults.
type VoteSummary ¶
type VoteSummary struct { Token string `json:"token"` // Censorship token BestBlock uint64 `json:"bestblock"` // Best block }
VoteSummary requests a summary of a proposal vote. This includes certain voting period parameters and a summary of the vote results.
func DecodeVoteSummary ¶
func DecodeVoteSummary(payload []byte) (*VoteSummary, error)
DecodeVoteSummary decodes a JSON byte slice into a VoteSummary.
type VoteSummaryReply ¶
type VoteSummaryReply struct { Authorized bool `json:"authorized"` // Vote is authorized Type VoteT `json:"type"` // Vote type Duration uint32 `json:"duration"` // Vote duration EndHeight string `json:"endheight"` // End block height EligibleTicketCount int `json:"eligibleticketcount"` // Number of eligible tickets QuorumPercentage uint32 `json:"quorumpercentage"` // Percent of eligible votes required for quorum PassPercentage uint32 `json:"passpercentage"` // Percent of total votes required to pass Results []VoteOptionResult `json:"results"` // Vote results Approved bool `json:"approved"` // Was vote approved }
VoteSummaryReply is the reply to the VoteSummary command and returns certain voting period parameters as well as a summary of the vote results.
func DecodeVoteSummaryReply ¶
func DecodeVoteSummaryReply(payload []byte) (*VoteSummaryReply, error)
DecodeVoteSummaryReply decodes a JSON byte slice into a VoteSummaryReply.
type VoteV1 ¶
type VoteV1 struct { Token string `json:"token"` // Token that identifies vote Mask uint64 `json:"mask"` // Valid votebits Duration uint32 `json:"duration"` // Duration in blocks QuorumPercentage uint32 `json:"quorumpercentage"` // Percent of eligible votes required for quorum PassPercentage uint32 `json:"passpercentage"` // Percent of total votes required to pass Options []VoteOption `json:"options"` // Vote option }
VoteV1 represents the vote options and parameters for a StartVoteV1.
func DecodeVoteV1 ¶
DecodeVoteV1 decodes a JSON byte slice into a VoteV1.
type VoteV2 ¶
type VoteV2 struct { Token string `json:"token"` // Token that identifies vote ProposalVersion uint32 `json:"proposalversion"` // Proposal version being voted on Type VoteT `json:"type"` // Type of vote Mask uint64 `json:"mask"` // Valid votebits Duration uint32 `json:"duration"` // Duration in blocks QuorumPercentage uint32 `json:"quorumpercentage"` // Percent of eligible votes required for quorum PassPercentage uint32 `json:"passpercentage"` // Percent of total votes required to pass Options []VoteOption `json:"options"` // Vote option }
VoteV2 represents the vote options and vote parameters for a StartVoteV2.
Differences between VoteV1 and VoteV2:
- Added the ProposalVersion field that specifies the version of the proposal that is being voted on. This was added so that the proposal version is explicitly included in the StartVote signature.
- Added a Type field in order to specify the vote type.
func DecodeVoteV2 ¶
DecodeVotedecodes a JSON byte slice into a VoteV2.