Documentation ¶
Index ¶
- Constants
- 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 EncodeCastVoteReply(cvr CastVoteReply) ([]byte, error)
- func EncodeCensorComment(cc CensorComment) ([]byte, error)
- func EncodeCensorCommentReply(ccr CensorCommentReply) ([]byte, error)
- func EncodeComment(c Comment) ([]byte, error)
- func EncodeGetComments(gc GetComments) ([]byte, error)
- func EncodeGetCommentsReply(gcr GetCommentsReply) ([]byte, error)
- func EncodeGetProposalCommentsLikes(gpcv GetProposalCommentsLikes) ([]byte, error)
- func EncodeGetProposalCommentsLikesReply(gpclr GetProposalCommentsLikesReply) ([]byte, error)
- func EncodeLikeComment(lc LikeComment) ([]byte, error)
- func EncodeLikeCommentReply(lcr LikeCommentReply) ([]byte, error)
- func EncodeNewComment(nc NewComment) ([]byte, error)
- func EncodeNewCommentReply(ncr NewCommentReply) ([]byte, error)
- func EncodeStartVote(v StartVote) ([]byte, error)
- func EncodeStartVoteReply(v StartVoteReply) ([]byte, error)
- func EncodeVote(v Vote) ([]byte, error)
- func EncodeVoteResults(v VoteResults) ([]byte, error)
- func EncodeVoteResultsReply(v VoteResultsReply) ([]byte, error)
- type AuthorizeVote
- type AuthorizeVoteReply
- type Ballot
- type BallotReply
- type CastVote
- type CastVoteReply
- type CensorComment
- type CensorCommentReply
- type Comment
- type GetComments
- type GetCommentsReply
- type GetProposalCommentsLikes
- type GetProposalCommentsLikesReply
- type LikeComment
- type LikeCommentReply
- type NewComment
- type NewCommentReply
- type StartVote
- type StartVoteReply
- type Vote
- type VoteOption
- type VoteResults
- type VoteResultsReply
Constants ¶
const ( Version = "1" ID = "HcashOrg" CmdAuthorizeVote = "authorizevote" CmdStartVote = "startvote" CmdBallot = "ballot" CmdBestBlock = "bestblock" CmdNewComment = "newcomment" CmdLikeComment = "likecomment" CmdCensorComment = "censorcomment" CmdGetComments = "getcomments" CmdProposalVotes = "proposalvotes" CmdProposalCommentsLikes = "proposalcommentslikes" MDStreamAuthorizeVote = 13 // Vote authorization by proposal author MDStreamVoteBits = 14 // Vote bits and mask MDStreamVoteSnapshot = 15 // Vote tickets and start/end parameters VoteDurationMin = 2016 // Minimum vote duration (in blocks) VoteDurationMax = 4032 // Maximum vote duration (in blocks) )
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 = 1
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 ¶
This section is empty.
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 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 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 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 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 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 ¶
EncodeStartVoteencodes StartVoteinto a JSON byte slice.
func EncodeStartVoteReply ¶
func EncodeStartVoteReply(v StartVoteReply) ([]byte, error)
EncodeStartVoteReply encodes StartVoteReply into a JSON byte slice.
func EncodeVote ¶
EncodeVote encodes Vote 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.
Types ¶
type AuthorizeVote ¶
type AuthorizeVote struct { // Generated by HcashOrgplugin 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 Receipt string `json:"receipt"` // Server signature of client signature }
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 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 if something wen't wrong during casting a vote }
CastVoteReply contains the signature or error to a cast vote command.
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 HcashOrgplugin 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 HcashOrg 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 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 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 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 pordown vote.
func DecodeLikeCommentReply ¶
func DecodeLikeCommentReply(payload []byte) (*LikeCommentReply, error)
DecodeLikeCommentReply decodes a JSON byte slice into a LikeCommentReply.
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 {
Comment Comment `json:"comment"` // Comment
}
NewCommentReply returns the comment as it was recorded in the journal.
func DecodeNewCommentReply ¶
func DecodeNewCommentReply(payload []byte) (*NewCommentReply, error)
DecodeNewCommentReply decodes a JSON byte slice into a NewCommentReply.
type StartVote ¶
type StartVote struct { // HcashOrg plugin only data Version uint `json:"version"` // Version of this structure PublicKey string `json:"publickey"` // Key used for signature. Vote Vote `json:"vote"` // Vote + options Signature string `json:"signature"` // Signature of Votehash }
func DecodeStartVote ¶
DecodeVotedecodes a JSON byte slice into a StartVote.
type StartVoteReply ¶
type StartVoteReply struct { // HcashOrg 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 Vote ¶
type Vote 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 }
Vote represents the vote options for vote that is identified by its token.
func DecodeVote ¶
DecodeVote decodes a JSON byte slice into a Vote.
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 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 { StartVote StartVote `json:"startvote"` // Original ballot CastVotes []CastVote `json:"castvotes"` // All votes }
func DecodeVoteResultsReply ¶
func DecodeVoteResultsReply(payload []byte) (*VoteResultsReply, error)
DecodeVoteResultsReply decodes a JSON byte slice into a VoteResults.