decredplugin

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: ISC Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version          = "1"
	ID               = "decred"
	CmdBestBlock     = "bestblock"
	CmdNewComment    = "newcomment"
	CmdCensorComment = "censorcomment"
	CmdGetComments   = "getcomments"
)

Plugin settings, kinda doesn;t go here but for now it is fine

Variables

View Source
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 EncodeBestBlock

func EncodeBestBlock(bb BestBlock) ([]byte, error)

EncodeBestBlock encodes an BestBlock into a JSON byte slice.

func EncodeBestBlockReply

func EncodeBestBlockReply(bbr BestBlockReply) ([]byte, error)

EncodeBestBlockReply encodes an BestBlockReply 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

func EncodeComment(c Comment) ([]byte, error)

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 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.

Types

type BestBlock

type BestBlock struct{}

BestBlock is a command to request the best block data.

func DecodeBestBlock

func DecodeBestBlock(payload []byte) (*BestBlock, error)

DecodeBestBlock decodes a JSON byte slice into a BestBlock.

type BestBlockReply

type BestBlockReply struct {
	Height uint32 `json:"height"`
}

BestBlockReply is the reply to the BestBlock command.

func DecodeBestBlockReply

func DecodeBestBlockReply(payload []byte) (*BestBlockReply, error)

DecodeBestBlockReply decodes a JSON byte slice into a BestBlockReply.

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

func DecodeComment(payload []byte) (*Comment, error)

DecodeComment decodes a JSON byte slice into a Comment

type ErrorStatusT

type ErrorStatusT int

ErrorStatusT represents decredplugin errors that result from casting a vote.

These are part of the www/v1 API and must stay in until the deprecated cast votes route is removed.

const (
	ErrorStatusInvalid          ErrorStatusT = 0
	ErrorStatusInternalError    ErrorStatusT = 1
	ErrorStatusProposalNotFound ErrorStatusT = 2
	ErrorStatusInvalidVoteBit   ErrorStatusT = 3
	ErrorStatusVoteHasEnded     ErrorStatusT = 4
	ErrorStatusDuplicateVote    ErrorStatusT = 5
	ErrorStatusIneligibleTicket ErrorStatusT = 6
	ErrorStatusLast             ErrorStatusT = 7
)

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 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.

Jump to

Keyboard shortcuts

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