diff --git a/internal/tss/store/store.go b/internal/tss/store/store.go index 5dcc97f..866f1cc 100644 --- a/internal/tss/store/store.go +++ b/internal/tss/store/store.go @@ -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) } diff --git a/internal/tss/types.go b/internal/tss/types.go index 0489bf6..372dc6e 100644 --- a/internal/tss/types.go +++ b/internal/tss/types.go @@ -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"