github.com/decred/politeia@v1.4.0/politeiad/backendv2/tstorebe/plugins/ticketvote/internalcmds.go (about) 1 // Copyright (c) 2020-2021 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 ticketvote 6 7 import "github.com/decred/politeia/politeiad/plugins/ticketvote" 8 9 const ( 10 // Internal plugin commands. These commands are not part of the 11 // public plugin API. They are for internal use only. 12 // 13 // These are are necessary because the command to start a runoff 14 // vote is executed on the parent record, but state is updated in 15 // all of the runoff vote submissions as well. Plugin commands 16 // should not be doing this. This is an exception and we use these 17 // internal plugin commands as a workaround. 18 cmdStartRunoffSubmission = "startrunoffsub" 19 cmdRunoffDetails = "runoffdetails" 20 ) 21 22 // startRunoffRecord is the record that is saved to the runoff vote's parent 23 // tree as the first step in starting a runoff vote. Plugins are not able to 24 // update multiple records atomically, so if this call gets interrupted before 25 // if can start the voting period on all runoff vote submissions, subsequent 26 // calls will use this record to pick up where the previous call left off. This 27 // allows us to recover from unexpected errors, such as network errors, and not 28 // leave a runoff vote in a weird state. 29 type startRunoffRecord struct { 30 Submissions []string `json:"submissions"` 31 Mask uint64 `json:"mask"` 32 Duration uint32 `json:"duration"` 33 QuorumPercentage uint32 `json:"quorumpercentage"` 34 PassPercentage uint32 `json:"passpercentage"` 35 StartBlockHeight uint32 `json:"startblockheight"` 36 StartBlockHash string `json:"startblockhash"` 37 EndBlockHeight uint32 `json:"endblockheight"` 38 EligibleTickets []string `json:"eligibletickets"` 39 } 40 41 // startRunoffSubmission is an internal plugin command that is used to start 42 // the voting period on a runoff vote submission. 43 type startRunoffSubmission struct { 44 ParentToken string `json:"parenttoken"` 45 StartDetails ticketvote.StartDetails `json:"startdetails"` 46 } 47 48 // startRunoffSubmissionReply is the reply to the startRunoffSubmission 49 // command. 50 type startRunoffSubmissionReply struct{} 51 52 // runoffDetails is an internal plugin command that requests the details of a 53 // runoff vote. 54 type runoffDetails struct{} 55 56 // runoffDetailsReply is the reply to the runoffDetails command. 57 type runoffDetailsReply struct { 58 Runoff startRunoffRecord `json:"runoff"` 59 }