Ensure previous vote choices are remembered. (#323)

This commit is contained in:
Jamie Holdstock 2022-02-02 15:04:53 +00:00 committed by GitHub
parent 040ed56f11
commit dcbf8a2c18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -102,7 +102,9 @@ func setVoteChoices(c *gin.Context) {
// Update VoteChoices in the database before updating the wallets. DB is the
// source of truth, and also is less likely to error.
ticket.VoteChoices = request.VoteChoices
for newAgenda, newChoice := range request.VoteChoices {
ticket.VoteChoices[newAgenda] = newChoice
}
err = db.UpdateTicket(ticket)
if err != nil {
@ -121,7 +123,7 @@ func setVoteChoices(c *gin.Context) {
for _, walletClient := range walletClients {
// Set consensus vote choices.
for agenda, choice := range request.VoteChoices {
for agenda, choice := range ticket.VoteChoices {
err = walletClient.SetVoteChoice(agenda, choice, ticket.Hash)
if err != nil {
log.Errorf("%s: dcrwallet.SetVoteChoice failed (wallet=%s, ticketHash=%s): %v",