Register tickets with invalid vote choices.

/payfee will no longer reject tickets with invalid vote choices. The tickets will be registered with the VSP and added to voting wallets, but their voting choices will be empty. A warning will be added to server logs.
This commit is contained in:
jholdstock 2020-11-12 10:53:14 +00:00 committed by David Hill
parent 04b07346c8
commit 0f657eb4fe

View File

@ -101,14 +101,14 @@ func payFee(c *gin.Context) {
return
}
// Validate VoteChoices.
voteChoices := request.VoteChoices
err = isValidVoteChoices(cfg.NetParams, currentVoteVersion(cfg.NetParams), voteChoices)
// Validate VoteChoices. Just log a warning if vote choices are not valid
// for the current vote version - the ticket should still be registered.
validVoteChoices := true
err = isValidVoteChoices(cfg.NetParams, currentVoteVersion(cfg.NetParams), request.VoteChoices)
if err != nil {
validVoteChoices = false
log.Warnf("%s: Invalid vote choices (clientIP=%s, ticketHash=%s): %v",
funcName, c.ClientIP(), ticket.Hash, err)
sendErrorWithMsg(err.Error(), errInvalidVoteChoices, c)
return
}
// Validate FeeTx.
@ -219,9 +219,12 @@ findAddress:
ticket.VotingWIF = votingWIF.String()
ticket.FeeTxHex = request.FeeTx
ticket.FeeTxHash = feeTx.TxHash().String()
ticket.VoteChoices = voteChoices
ticket.FeeTxStatus = database.FeeReceieved
if validVoteChoices {
ticket.VoteChoices = request.VoteChoices
}
err = db.UpdateTicket(ticket)
if err != nil {
log.Errorf("%s: db.UpdateTicket error, failed to set fee tx (ticketHash=%s): %v",