From 32570732f449b0c2c1f1c335d976506e4bff4f36 Mon Sep 17 00:00:00 2001 From: Nate Maninger Date: Thu, 12 Sep 2024 10:21:17 -0700 Subject: [PATCH] api: change tpool response to 400 --- api/server.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/server.go b/api/server.go index 51df847..224fcd3 100644 --- a/api/server.go +++ b/api/server.go @@ -3,6 +3,7 @@ package api import ( "context" "errors" + "fmt" "net/http" "net/http/pprof" "reflect" @@ -296,7 +297,8 @@ func (s *server) txpoolBroadcastHandler(jc jape.Context) { } if len(tbr.Transactions) != 0 { _, err := s.cm.AddPoolTransactions(tbr.Transactions) - if jc.Check("invalid transaction set", err) != nil { + if err != nil { + jc.Error(fmt.Errorf("invalid transaction set: %w", err), http.StatusBadRequest) return } s.s.BroadcastTransactionSet(tbr.Transactions) @@ -304,7 +306,8 @@ func (s *server) txpoolBroadcastHandler(jc jape.Context) { if len(tbr.V2Transactions) != 0 { index := s.cm.TipState().Index _, err := s.cm.AddV2PoolTransactions(index, tbr.V2Transactions) - if jc.Check("invalid v2 transaction set", err) != nil { + if err != nil { + jc.Error(fmt.Errorf("invalid v2 transaction set: %w", err), http.StatusBadRequest) return } s.s.BroadcastV2TransactionSet(index, tbr.V2Transactions)