Skip to content

Commit

Permalink
Code()
Browse files Browse the repository at this point in the history
  • Loading branch information
gouthamp-stellar committed Sep 21, 2024
1 parent e28ff02 commit 4793f90
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
9 changes: 1 addition & 8 deletions internal/tss/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,7 @@ func (s *store) UpsertTry(ctx context.Context, txHash string, feeBumpTxHash stri
status = $4,
updated_at = NOW();
`
var st int
// if this value is set, it takes precedence over the code from RPC
if status.OtherCodes != tss.NoCode {
st = int(status.OtherCodes)
} else {
st = int(status.TxResultCode)
}
_, err := s.DB.ExecContext(ctx, q, txHash, feeBumpTxHash, feeBumpTxXDR, st)
_, err := s.DB.ExecContext(ctx, q, txHash, feeBumpTxHash, feeBumpTxXDR, status.Code())
if err != nil {
return fmt.Errorf("inserting/updating tss try: %w", err)
}
Expand Down
7 changes: 7 additions & 0 deletions internal/tss/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ type RPCTXCode struct {
OtherCodes OtherCodes
}

func (c RPCTXCode) Code() int {
if c.OtherCodes != NoCode {
return int(c.OtherCodes)
}
return int(c.TxResultCode)
}

const (
// Brand new transaction, not sent to RPC yet
NewStatus RPCTXStatus = "NEW"
Expand Down

0 comments on commit 4793f90

Please sign in to comment.