github.com/decred/politeia@v1.4.0/politeiad/cmd/legacypoliteia/gitbe/mdstreams.go (about) 1 // Copyright (c) 2022 The Decred developers 2 // Use of this source code is governed by an ISC 3 // license that can be found in the LICENSE file. 4 5 package gitbe 6 7 const ( 8 // Metadata stream filenames 9 MDStreamProposalGeneral = "00.metadata.txt" 10 MDStreamStatusChanges = "02.metadata.txt" 11 MDStreamAuthorizeVote = "13.metadata.txt" 12 MDStreamStartVote = "14.metadata.txt" 13 MDStreamStartVoteReply = "15.metadata.txt" 14 ) 15 16 // ProposalGeneralV2 represents general metadata for a proposal. 17 // 18 // Signature is the signature of the proposal merkle root. The merkle root 19 // contains the ordered files and metadata digests. The file digests are first 20 // in the ordering. 21 // 22 // Differences between v1 and v2: 23 // * Name has been removed and is now part of proposal metadata. 24 // * Signature has been updated to include propoposal metadata. 25 type ProposalGeneralV2 struct { 26 Version uint64 `json:"version"` // Struct version 27 Timestamp int64 `json:"timestamp"` // Last update of proposal 28 PublicKey string `json:"publickey"` // Key used for signature 29 Signature string `json:"signature"` // Proposal signature 30 } 31 32 type RecordStatusT int 33 34 var ( 35 RecordStatusInvalid RecordStatusT = 0 36 RecordStatusNotFound RecordStatusT = 1 37 RecordStatusNotReviewed RecordStatusT = 2 38 RecordStatusCensored RecordStatusT = 3 39 RecordStatusPublic RecordStatusT = 4 40 RecordStatusUnreviewedChanges RecordStatusT = 5 41 RecordStatusArchived RecordStatusT = 6 42 ) 43 44 // RecordStatusChangeV2 represents a politeiad record status change and is used 45 // to store additional status change metadata that would not otherwise be 46 // captured by the politeiad status change routes. 47 // 48 // V2 adds the Signature field, which was erroneously left out of V1. 49 // 50 // Signature of is the signature of Token + NewStatus + StatusChangeMessage. 51 type RecordStatusChangeV2 struct { 52 Version uint `json:"version"` // Version of this struct 53 NewStatus RecordStatusT `json:"newstatus"` 54 StatusChangeMessage string `json:"statuschangemessage,omitempty"` 55 Signature string `json:"signature"` 56 AdminPubKey string `json:"adminpubkey"` 57 Timestamp int64 `json:"timestamp"` 58 } 59 60 // AuthorizeVote is an MDStream that is used to indicate that a proposal has 61 // been finalized and is ready to be voted on. The signature and public 62 // key are from the proposal author. The author can revoke a previously sent 63 // vote authorization by setting the Action field to revoke. 64 type AuthorizeVote struct { 65 // Generated by decredplugin 66 Version uint `json:"version"` // Version of this structure 67 Receipt string `json:"receipt"` // Server signature of client signature 68 Timestamp int64 `json:"timestamp"` // Received UNIX timestamp 69 70 // Generated by client 71 Action string `json:"action"` // Authorize or revoke 72 Token string `json:"token"` // Proposal censorship token 73 Signature string `json:"signature"` // Signature of token+version+action 74 PublicKey string `json:"publickey"` // Pubkey used for signature 75 } 76 77 // StartVoteV1 was formerly used to start a proposal vote, but is not longer 78 // accepted. A StartVoteV2 must be used to start a proposal vote. 79 type StartVoteV1 struct { 80 Version uint `json:"version"` // Version of this structure 81 PublicKey string `json:"publickey"` // Key used for signature 82 Vote VoteV1 `json:"vote"` // Vote + options 83 Signature string `json:"signature"` // Signature of token 84 } 85 86 // VoteV1 represents the vote options and parameters for a StartVoteV1. 87 type VoteV1 struct { 88 Token string `json:"token"` 89 Mask uint64 `json:"mask"` 90 Duration uint32 `json:"duration"` 91 QuorumPercentage uint32 `json:"quorumpercentage"` 92 PassPercentage uint32 `json:"passpercentage"` 93 Options []VoteOption `json:"options"` 94 } 95 96 // VoteOption describes a single vote option. 97 type VoteOption struct { 98 Id string `json:"id"` 99 Description string `json:"description"` 100 Bits uint64 `json:"bits"` 101 } 102 103 // StartVoteV2 is used to start a proposal vote. 104 // 105 // The message being signed is the SHA256 digest of the VoteV2 JSON byte slice. 106 // 107 // Differences between StartVoteV1 and StartVoteV2: 108 // - Signature is the signature of a hash of the Vote struct. It was 109 // previously the signature of just the proposal token. 110 // - Vote is now a VoteV2. See the VoteV2 comment for more details. 111 type StartVoteV2 struct { 112 Version uint `json:"version"` // Version of this structure 113 PublicKey string `json:"publickey"` // Key used for signature 114 Vote VoteV2 `json:"vote"` // Vote options and params 115 Signature string `json:"signature"` // Signature of Vote hash 116 } 117 118 // VoteV2 represents the vote options and vote parameters for a StartVoteV2. 119 // 120 // Differences between VoteV1 and VoteV2: 121 // - Added the ProposalVersion field that specifies the version of the proposal 122 // that is being voted on. This was added so that the proposal version is 123 // explicitly included in the StartVote signature. 124 // - Added a Type field in order to specify the vote type. 125 type VoteV2 struct { 126 Token string `json:"token"` 127 ProposalVersion uint32 `json:"proposalversion"` 128 Type VoteT `json:"type"` 129 Mask uint64 `json:"mask"` 130 Duration uint32 `json:"duration"` 131 QuorumPercentage uint32 `json:"quorumpercentage"` 132 PassPercentage uint32 `json:"passpercentage"` 133 Options []VoteOption `json:"options"` 134 } 135 136 // VoteT represents the different type of votes. 137 type VoteT int 138 139 var ( 140 VoteTypeInvalid VoteT = 0 141 VoteTypeStandard VoteT = 1 142 VoteTypeRunoff VoteT = 2 143 ) 144 145 // StartVoteReply is the reply to StartVote. 146 type StartVoteReply struct { 147 Version uint `json:"version"` // Version of this struct 148 StartBlockHeight string `json:"startblockheight"` // Block height 149 StartBlockHash string `json:"startblockhash"` // Block hash 150 EndHeight string `json:"endheight"` // Height of vote end 151 EligibleTickets []string `json:"eligibletickets"` // Valid voting tickets 152 }