Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio committed Jan 9, 2025
1 parent 9e45cac commit e9cf423
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
19 changes: 9 additions & 10 deletions cmd/stellar-rpc/internal/methods/get_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,21 @@ func (g *GetEventsRequest) Valid(maxLimit uint) error {
}
}

if g.Pagination != nil {
if g.Pagination != nil { //nolint:nestif
if g.Pagination.Cursor != nil && (g.StartLedger != 0 || g.EndLedger != 0) {
return errors.New("ledger ranges and cursor cannot both be set")
}
if g.Pagination.Limit > maxLimit {
return fmt.Errorf("limit must not exceed %d", maxLimit)
}
return nil
}

// Pagination not enabled
if g.StartLedger <= 0 {
return errors.New("startLedger must be positive")
}
if g.EndLedger > 0 && g.EndLedger < g.StartLedger {
return errors.New("startLedger must be <= endLedger")
} else {
// Pagination not enabled
if g.StartLedger <= 0 {
return errors.New("startLedger must be positive")
}
if g.EndLedger > 0 && g.EndLedger < g.StartLedger {
return errors.New("startLedger must be <= endLedger")
}
}

return nil
Expand Down
6 changes: 2 additions & 4 deletions cmd/stellar-rpc/internal/methods/get_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,14 @@ func (req GetTransactionsRequest) isValid(maxLimit uint, ledgerRange ledgerbucke
if req.Pagination.Limit > maxLimit {
return fmt.Errorf("limit must not exceed %d", maxLimit)
}
return nil
}
// Pagination is not enabled
if req.StartLedger < ledgerRange.FirstLedger.Sequence || req.StartLedger > ledgerRange.LastLedger.Sequence {
} else if req.StartLedger < ledgerRange.FirstLedger.Sequence || req.StartLedger > ledgerRange.LastLedger.Sequence {
return fmt.Errorf(
"start ledger must be between the oldest ledger: %d and the latest ledger: %d for this rpc instance",
ledgerRange.FirstLedger.Sequence,
ledgerRange.LastLedger.Sequence,
)
}

return nil
}

Expand Down

0 comments on commit e9cf423

Please sign in to comment.