Skip to content

Commit

Permalink
Merge pull request #177 from SiaFoundation/nate/tpool-400-response
Browse files Browse the repository at this point in the history
Change tpool response to 400
  • Loading branch information
lukechampine authored Sep 12, 2024
2 parents 134a28b + 3257073 commit 6ff23fe
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package api
import (
"context"
"errors"
"fmt"
"net/http"
"net/http/pprof"
"reflect"
Expand Down Expand Up @@ -296,15 +297,17 @@ 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)
}
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)
Expand Down

0 comments on commit 6ff23fe

Please sign in to comment.