Skip to content

Commit

Permalink
trace txByNonce (#2930)
Browse files Browse the repository at this point in the history
[goreleaser]

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>
  • Loading branch information
trajan0x and trajan0x authored Jul 28, 2024
1 parent 442bf9b commit 806c12d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion services/rfq/relayer/relapi/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"github.com/synapsecns/sanguine/core/metrics"
"go.opentelemetry.io/otel/attribute"
"math/big"
"net/http"

Expand Down Expand Up @@ -262,6 +263,12 @@ type GetTxByNonceRequest struct {

// GetTxHashByNonce gets the transaction hash by submitter nonce.
func (h *Handler) GetTxHashByNonce(c *gin.Context) {
ctx, span := h.metrics.Tracer().Start(c, "txByNonce")
var err error
defer func() {
metrics.EndSpanWithErr(span, err)
}()

chainIDStr := c.Query("chain_id")
nonceStr := c.Query("nonce")

Expand All @@ -271,13 +278,16 @@ func (h *Handler) GetTxHashByNonce(c *gin.Context) {
return
}

span.SetAttributes(attribute.Int("chain_id", int(chainID.Uint64())))

nonce, ok := new(big.Int).SetString(nonceStr, 10)
if !ok {
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid nonce"})
return
}
span.SetAttributes(attribute.Int("nonce", int(nonce.Uint64())))

tx, err := h.submitter.GetSubmissionStatus(c, chainID, nonce.Uint64())
tx, err := h.submitter.GetSubmissionStatus(ctx, chainID, nonce.Uint64())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": fmt.Sprintf("could not get tx hash: %s", err.Error())})
return
Expand Down

0 comments on commit 806c12d

Please sign in to comment.