Skip to content

Commit

Permalink
soroban-rpc: getLedgerEntries: set maximum number of keys to query for (
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio authored Aug 29, 2023
1 parent 0d3fbcb commit f7de99a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/soroban-rpc/internal/methods/get_ledger_entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,17 @@ type GetLedgerEntriesResponse struct {
LatestLedger int64 `json:"latestLedger,string"`
}

const getLedgerEntriesMaxKeys = 200

// NewGetLedgerEntriesHandler returns a JSON RPC handler to retrieve the specified ledger entries from Stellar Core.
func NewGetLedgerEntriesHandler(logger *log.Entry, ledgerEntryReader db.LedgerEntryReader) jrpc2.Handler {
return handler.New(func(ctx context.Context, request GetLedgerEntriesRequest) (GetLedgerEntriesResponse, error) {
if len(request.Keys) > getLedgerEntriesMaxKeys {
return GetLedgerEntriesResponse{}, &jrpc2.Error{
Code: jrpc2.InvalidParams,
Message: fmt.Sprintf("key count (%d) exceeds maximum supported (%d)", len(request.Keys), getLedgerEntriesMaxKeys),
}
}
var ledgerKeys []xdr.LedgerKey
for i, requestKey := range request.Keys {
var ledgerKey xdr.LedgerKey
Expand Down

0 comments on commit f7de99a

Please sign in to comment.