/
voteresults.go
76 lines (66 loc) · 2.19 KB
/
voteresults.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright (c) 2017-2019 The Bitum developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package commands
// VoteResultsCmd gets the votes that have been cast for the specified
// proposal.
type VoteResultsCmd struct {
Args struct {
Token string `positional-arg-name:"token"` // Censorship token
} `positional-args:"true" required:"true"`
}
// Execute executes the proposal votes command.
func (cmd *VoteResultsCmd) Execute(args []string) error {
vrr, err := client.VoteResults(cmd.Args.Token)
if err != nil {
return err
}
// Remove eligible tickets snapshot from response
// so that the output is legible
if !cfg.RawJSON {
vrr.StartVoteReply.EligibleTickets = []string{
"removed by politeiawwwcli for readability",
}
}
return printJSON(vrr)
}
// voteResultsHelpMsg is the output of the help command when 'voteresults' is
// specified.
const voteResultsHelpMsg = `voteresults "token"
Fetch vote results for a proposal.
Arguments:
1. token (string, required) Proposal censorship token
Request:
{
"token": (string) Proposal censorship token
}
Response:
{
"startvote": {
"publickey" (string) Public key of user that submitted proposal
"vote": {
"token": (string) Censorship token
"mask" (uint64) Valid votebits
"duration": (uint32) Duration of vote in blocks
"quorumpercentage" (uint32) Percent of votes required for quorum
"passpercentage": (uint32) Percent of votes required to pass
"options": [
{
"id" (string) Unique word identifying vote (e.g. yes)
"description" (string) Longer description of the vote
"bits": (uint64) Bits used for this option
},
]
},
"signature" (string) Signature of Votehash
},
"castvotes": [],
"startvotereply": {
"startblockheight": (string) Block height at start of vote
"startblockhash": (string) Hash of first block of vote interval
"endheight": (string) Block height at end of vote
"eligibletickets": [
"removed by politeiawwwcli for readability"
]
}
}`