Don't export types unnecessarily
This commit is contained in:
parent
b8c6ffe1e0
commit
bcb6fd5ec3
@ -73,14 +73,14 @@ func feeAddress(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
var feeAddressRequest FeeAddressRequest
|
||||
if err := c.ShouldBindJSON(&feeAddressRequest); err != nil {
|
||||
var request feeAddressRequest
|
||||
if err := c.ShouldBindJSON(&request); err != nil {
|
||||
log.Warnf("%s: Bad request (clientIP=%s): %v", funcName, c.ClientIP(), err)
|
||||
sendErrorWithMsg(err.Error(), errBadRequest, c)
|
||||
return
|
||||
}
|
||||
|
||||
ticketHash := feeAddressRequest.TicketHash
|
||||
ticketHash := request.TicketHash
|
||||
|
||||
// Respond early if we already have the fee tx for this ticket.
|
||||
if ticket.FeeTxStatus == database.FeeReceieved ||
|
||||
@ -141,7 +141,7 @@ func feeAddress(c *gin.Context) {
|
||||
}
|
||||
sendJSONResponse(feeAddressResponse{
|
||||
Timestamp: now.Unix(),
|
||||
Request: feeAddressRequest,
|
||||
Request: request,
|
||||
FeeAddress: ticket.FeeAddress,
|
||||
FeeAmount: ticket.FeeAmount,
|
||||
Expiration: ticket.FeeExpiration,
|
||||
@ -194,7 +194,7 @@ func feeAddress(c *gin.Context) {
|
||||
|
||||
sendJSONResponse(feeAddressResponse{
|
||||
Timestamp: now.Unix(),
|
||||
Request: feeAddressRequest,
|
||||
Request: request,
|
||||
FeeAddress: newAddress,
|
||||
FeeAmount: int64(fee),
|
||||
Expiration: expire,
|
||||
|
||||
@ -32,8 +32,8 @@ func payFee(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
var payFeeRequest PayFeeRequest
|
||||
if err := c.ShouldBindJSON(&payFeeRequest); err != nil {
|
||||
var request payFeeRequest
|
||||
if err := c.ShouldBindJSON(&request); err != nil {
|
||||
log.Warnf("%s: Bad request (clientIP=%s): %v", funcName, c.ClientIP(), err)
|
||||
sendErrorWithMsg(err.Error(), errBadRequest, c)
|
||||
return
|
||||
@ -80,7 +80,7 @@ func payFee(c *gin.Context) {
|
||||
}
|
||||
|
||||
// Validate VotingKey.
|
||||
votingKey := payFeeRequest.VotingKey
|
||||
votingKey := request.VotingKey
|
||||
votingWIF, err := dcrutil.DecodeWIF(votingKey, cfg.NetParams.PrivateKeyID)
|
||||
if err != nil {
|
||||
log.Warnf("%s: Failed to decode WIF (clientIP=%s, ticketHash=%s): %v",
|
||||
@ -90,7 +90,7 @@ func payFee(c *gin.Context) {
|
||||
}
|
||||
|
||||
// Validate VoteChoices.
|
||||
voteChoices := payFeeRequest.VoteChoices
|
||||
voteChoices := request.VoteChoices
|
||||
err = isValidVoteChoices(cfg.NetParams, currentVoteVersion(cfg.NetParams), voteChoices)
|
||||
if err != nil {
|
||||
log.Warnf("%s: Invalid vote choices (clientIP=%s, ticketHash=%s): %v",
|
||||
@ -100,7 +100,7 @@ func payFee(c *gin.Context) {
|
||||
}
|
||||
|
||||
// Validate FeeTx.
|
||||
feeTx, err := decodeTransaction(payFeeRequest.FeeTx)
|
||||
feeTx, err := decodeTransaction(request.FeeTx)
|
||||
if err != nil {
|
||||
log.Warnf("%s: Failed to decode fee tx hex (clientIP=%s, ticketHash=%s): %v",
|
||||
funcName, c.ClientIP(), ticket.Hash, err)
|
||||
@ -205,7 +205,7 @@ findAddress:
|
||||
// database, and if the ticket is confirmed broadcast the transaction.
|
||||
|
||||
ticket.VotingWIF = votingWIF.String()
|
||||
ticket.FeeTxHex = payFeeRequest.FeeTx
|
||||
ticket.FeeTxHex = request.FeeTx
|
||||
ticket.FeeTxHash = feeTx.TxHash().String()
|
||||
ticket.VoteChoices = voteChoices
|
||||
ticket.FeeTxStatus = database.FeeReceieved
|
||||
@ -222,7 +222,7 @@ findAddress:
|
||||
funcName, minFee, feePaid, ticket.Hash)
|
||||
|
||||
if ticket.Confirmed {
|
||||
err = dcrdClient.SendRawTransaction(payFeeRequest.FeeTx)
|
||||
err = dcrdClient.SendRawTransaction(request.FeeTx)
|
||||
if err != nil {
|
||||
log.Errorf("%s: dcrd.SendRawTransaction for fee tx failed (ticketHash=%s): %v",
|
||||
funcName, ticket.Hash, err)
|
||||
@ -255,6 +255,6 @@ findAddress:
|
||||
|
||||
sendJSONResponse(payFeeResponse{
|
||||
Timestamp: time.Now().Unix(),
|
||||
Request: payFeeRequest,
|
||||
Request: request,
|
||||
}, c)
|
||||
}
|
||||
|
||||
@ -30,14 +30,14 @@ func setVoteChoices(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
var setVoteChoicesRequest SetVoteChoicesRequest
|
||||
if err := c.ShouldBindJSON(&setVoteChoicesRequest); err != nil {
|
||||
var request setVoteChoicesRequest
|
||||
if err := c.ShouldBindJSON(&request); err != nil {
|
||||
log.Warnf("%s: Bad request (clientIP=%s): %v", funcName, c.ClientIP(), err)
|
||||
sendErrorWithMsg(err.Error(), errBadRequest, c)
|
||||
return
|
||||
}
|
||||
|
||||
voteChoices := setVoteChoicesRequest.VoteChoices
|
||||
voteChoices := request.VoteChoices
|
||||
err := isValidVoteChoices(cfg.NetParams, currentVoteVersion(cfg.NetParams), voteChoices)
|
||||
if err != nil {
|
||||
log.Warnf("%s: Invalid vote choices (clientIP=%s, ticketHash=%s): %v",
|
||||
@ -81,6 +81,6 @@ func setVoteChoices(c *gin.Context) {
|
||||
|
||||
sendJSONResponse(setVoteChoicesResponse{
|
||||
Timestamp: time.Now().Unix(),
|
||||
Request: setVoteChoicesRequest,
|
||||
Request: request,
|
||||
}, c)
|
||||
}
|
||||
|
||||
@ -21,8 +21,8 @@ func ticketStatus(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
var ticketStatusRequest TicketStatusRequest
|
||||
if err := c.ShouldBindJSON(&ticketStatusRequest); err != nil {
|
||||
var request ticketStatusRequest
|
||||
if err := c.ShouldBindJSON(&request); err != nil {
|
||||
log.Warnf("%s: Bad request (clientIP=%s): %v", funcName, c.ClientIP(), err)
|
||||
sendErrorWithMsg(err.Error(), errBadRequest, c)
|
||||
return
|
||||
@ -30,7 +30,7 @@ func ticketStatus(c *gin.Context) {
|
||||
|
||||
sendJSONResponse(ticketStatusResponse{
|
||||
Timestamp: time.Now().Unix(),
|
||||
Request: ticketStatusRequest,
|
||||
Request: request,
|
||||
TicketConfirmed: ticket.Confirmed,
|
||||
FeeTxStatus: string(ticket.FeeTxStatus),
|
||||
FeeTxHash: ticket.FeeTxHash,
|
||||
|
||||
@ -13,7 +13,7 @@ type vspInfoResponse struct {
|
||||
Revoked int64 `json:"revoked"`
|
||||
}
|
||||
|
||||
type FeeAddressRequest struct {
|
||||
type feeAddressRequest struct {
|
||||
Timestamp int64 `json:"timestamp" binding:"required"`
|
||||
TicketHash string `json:"tickethash" binding:"required"`
|
||||
TicketHex string `json:"tickethex" binding:"required"`
|
||||
@ -24,10 +24,10 @@ type feeAddressResponse struct {
|
||||
FeeAddress string `json:"feeaddress"`
|
||||
FeeAmount int64 `json:"feeamount"`
|
||||
Expiration int64 `json:"expiration"`
|
||||
Request FeeAddressRequest `json:"request"`
|
||||
Request feeAddressRequest `json:"request"`
|
||||
}
|
||||
|
||||
type PayFeeRequest struct {
|
||||
type payFeeRequest struct {
|
||||
Timestamp int64 `json:"timestamp" binding:"required"`
|
||||
TicketHash string `json:"tickethash" binding:"required"`
|
||||
FeeTx string `json:"feetx" binding:"required"`
|
||||
@ -37,10 +37,10 @@ type PayFeeRequest struct {
|
||||
|
||||
type payFeeResponse struct {
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Request PayFeeRequest `json:"request"`
|
||||
Request payFeeRequest `json:"request"`
|
||||
}
|
||||
|
||||
type SetVoteChoicesRequest struct {
|
||||
type setVoteChoicesRequest struct {
|
||||
Timestamp int64 `json:"timestamp" binding:"required"`
|
||||
TicketHash string `json:"tickethash" binding:"required"`
|
||||
VoteChoices map[string]string `json:"votechoices" binding:"required"`
|
||||
@ -48,10 +48,10 @@ type SetVoteChoicesRequest struct {
|
||||
|
||||
type setVoteChoicesResponse struct {
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Request SetVoteChoicesRequest `json:"request"`
|
||||
Request setVoteChoicesRequest `json:"request"`
|
||||
}
|
||||
|
||||
type TicketStatusRequest struct {
|
||||
type ticketStatusRequest struct {
|
||||
TicketHash string `json:"tickethash" binding:"required"`
|
||||
}
|
||||
|
||||
@ -61,5 +61,5 @@ type ticketStatusResponse struct {
|
||||
FeeTxStatus string `json:"feetxstatus"`
|
||||
FeeTxHash string `json:"feetxhash"`
|
||||
VoteChoices map[string]string `json:"votechoices"`
|
||||
Request TicketStatusRequest `json:"request"`
|
||||
Request ticketStatusRequest `json:"request"`
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user