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