Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

politeiavoter: Improve summary printing. #1594

Merged
merged 1 commit into from Dec 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 19 additions & 3 deletions politeiawww/cmd/politeiavoter/politeiavoter.go
Expand Up @@ -1033,15 +1033,31 @@ func (p *piv) vote(args []string) error {
err := p._vote(args[0], args[1])
// we return err after printing details

// Verify vote replies
// Verify vote replies. Already voted errors are not
// considered to be failures because they occur when
// a network error or dropped client connection causes
// politeiavoter to incorrectly think that the first
// attempt to cast the vote failed. politeiavoter will
// attempt to retry the vote that it has already
// successfully cast, resulting in the already voted
// error.
var alreadyVoted int
failedReceipts := make([]tkv1.CastVoteReply, 0,
len(p.ballotResults))
for _, v := range p.ballotResults {
if v.ErrorContext != "" {
failedReceipts = append(failedReceipts, v)
if v.ErrorCode == nil {
continue
}
if *v.ErrorCode == tkv1.VoteErrorTicketAlreadyVoted {
alreadyVoted++
continue
}
failedReceipts = append(failedReceipts, v)
}

log.Debugf("%v already voted errors found; these are "+
"counted as being successful", alreadyVoted)

fmt.Printf("Votes succeeded: %v\n", len(p.ballotResults)-
len(failedReceipts))
fmt.Printf("Votes failed : %v\n", len(failedReceipts))
Expand Down