Check if fee already paid before checking if ticket is votable

This commit is contained in:
jholdstock 2020-06-03 15:47:40 +01:00 committed by David Hill
parent fb4dd039d8
commit dcfc2e969d

View File

@ -83,6 +83,13 @@ func feeAddress(c *gin.Context) {
ticketHash := feeAddressRequest.TicketHash ticketHash := feeAddressRequest.TicketHash
// Respond early if we already have the fee tx for this ticket.
if ticket.FeeTxHex != "" {
log.Warnf("Fee tx already received from %s: ticketHash=%s", c.ClientIP(), ticket.Hash)
sendErrorResponse("fee tx already received", http.StatusBadRequest, c)
return
}
canVote, err := dcrdClient.CanTicketVote(ticketHash, cfg.NetParams) canVote, err := dcrdClient.CanTicketVote(ticketHash, cfg.NetParams)
if err != nil { if err != nil {
log.Errorf("canTicketVote error: %v", err) log.Errorf("canTicketVote error: %v", err)
@ -98,13 +105,6 @@ func feeAddress(c *gin.Context) {
// VSP already knows this ticket and has already issued it a fee address. // VSP already knows this ticket and has already issued it a fee address.
if knownTicket { if knownTicket {
// Respond early if we already have the fee tx for this ticket.
if ticket.FeeTxHex != "" {
log.Warnf("Fee tx already received from %s: ticketHash=%s", c.ClientIP(), ticket.Hash)
sendErrorResponse("fee tx already received", http.StatusBadRequest, c)
return
}
// If the expiry period has passed we need to issue a new fee. // If the expiry period has passed we need to issue a new fee.
now := time.Now() now := time.Now()
if ticket.FeeExpired() { if ticket.FeeExpired() {