Use actual request in response, dont reserialize. (#220)

Reserializing the client request can result in different bytes because
the order of iteration over a map is not guaranteed to be the same every
time.
This commit is contained in:
Jamie Holdstock 2020-12-30 12:36:06 +00:00 committed by GitHub
parent 268d293749
commit ac8e20f3c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 20 deletions

View File

@ -147,7 +147,7 @@ func feeAddress(c *gin.Context) {
} }
sendJSONResponse(feeAddressResponse{ sendJSONResponse(feeAddressResponse{
Timestamp: now.Unix(), Timestamp: now.Unix(),
Request: request, Request: reqBytes,
FeeAddress: ticket.FeeAddress, FeeAddress: ticket.FeeAddress,
FeeAmount: ticket.FeeAmount, FeeAmount: ticket.FeeAmount,
Expiration: ticket.FeeExpiration, Expiration: ticket.FeeExpiration,
@ -200,7 +200,7 @@ func feeAddress(c *gin.Context) {
sendJSONResponse(feeAddressResponse{ sendJSONResponse(feeAddressResponse{
Timestamp: now.Unix(), Timestamp: now.Unix(),
Request: request, Request: reqBytes,
FeeAddress: newAddress, FeeAddress: newAddress,
FeeAmount: int64(fee), FeeAmount: int64(fee),
Expiration: expire, Expiration: expire,

View File

@ -276,7 +276,7 @@ findAddress:
// Send success response to client. // Send success response to client.
resp, respSig := sendJSONResponse(payFeeResponse{ resp, respSig := sendJSONResponse(payFeeResponse{
Timestamp: time.Now().Unix(), Timestamp: time.Now().Unix(),
Request: request, Request: reqBytes,
}, c) }, c)
// Store a record of the vote choice change. // Store a record of the vote choice change.

View File

@ -134,7 +134,7 @@ func setVoteChoices(c *gin.Context) {
// Send success response to client. // Send success response to client.
resp, respSig := sendJSONResponse(setVoteChoicesResponse{ resp, respSig := sendJSONResponse(setVoteChoicesResponse{
Timestamp: time.Now().Unix(), Timestamp: time.Now().Unix(),
Request: request, Request: reqBytes,
}, c) }, c)
// Store a record of the vote choice change. // Store a record of the vote choice change.

View File

@ -36,7 +36,7 @@ func ticketStatus(c *gin.Context) {
sendJSONResponse(ticketStatusResponse{ sendJSONResponse(ticketStatusResponse{
Timestamp: time.Now().Unix(), Timestamp: time.Now().Unix(),
Request: request, Request: reqBytes,
TicketConfirmed: ticket.Confirmed, TicketConfirmed: ticket.Confirmed,
FeeTxStatus: string(ticket.FeeTxStatus), FeeTxStatus: string(ticket.FeeTxStatus),
FeeTxHash: ticket.FeeTxHash, FeeTxHash: ticket.FeeTxHash,

View File

@ -29,7 +29,7 @@ type feeAddressResponse struct {
FeeAddress string `json:"feeaddress"` FeeAddress string `json:"feeaddress"`
FeeAmount int64 `json:"feeamount"` FeeAmount int64 `json:"feeamount"`
Expiration int64 `json:"expiration"` Expiration int64 `json:"expiration"`
Request feeAddressRequest `json:"request"` Request []byte `json:"request"`
} }
type payFeeRequest struct { type payFeeRequest struct {
@ -42,7 +42,7 @@ type payFeeRequest struct {
type payFeeResponse struct { type payFeeResponse struct {
Timestamp int64 `json:"timestamp"` Timestamp int64 `json:"timestamp"`
Request payFeeRequest `json:"request"` Request []byte `json:"request"`
} }
type setVoteChoicesRequest struct { type setVoteChoicesRequest struct {
@ -53,7 +53,7 @@ type setVoteChoicesRequest struct {
type setVoteChoicesResponse struct { type setVoteChoicesResponse struct {
Timestamp int64 `json:"timestamp"` Timestamp int64 `json:"timestamp"`
Request setVoteChoicesRequest `json:"request"` Request []byte `json:"request"`
} }
type ticketStatusRequest struct { type ticketStatusRequest struct {
@ -66,5 +66,5 @@ type ticketStatusResponse struct {
FeeTxStatus string `json:"feetxstatus"` FeeTxStatus string `json:"feetxstatus"`
FeeTxHash string `json:"feetxhash"` FeeTxHash string `json:"feetxhash"`
VoteChoices map[string]string `json:"votechoices"` VoteChoices map[string]string `json:"votechoices"`
Request ticketStatusRequest `json:"request"` Request []byte `json:"request"`
} }