From 5156b9ea0ad55674b4527a5c6a1b7cdda9efe31f Mon Sep 17 00:00:00 2001 From: Aditya Vyas Date: Tue, 16 Apr 2024 14:35:17 -0400 Subject: [PATCH] Add config-options for tx pagination limits --- cmd/soroban-rpc/internal/config/options.go | 22 +++++++++++++++++++ .../internal/methods/get_transactions.go | 8 ------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/cmd/soroban-rpc/internal/config/options.go b/cmd/soroban-rpc/internal/config/options.go index df503200..d9099dd4 100644 --- a/cmd/soroban-rpc/internal/config/options.go +++ b/cmd/soroban-rpc/internal/config/options.go @@ -247,6 +247,28 @@ func (cfg *Config) options() ConfigOptions { return nil }, }, + { + Name: "max-transactions-limit", + Usage: "Maximum amount of transactions allowed in a single getTransactions response", + ConfigKey: &cfg.MaxTransactionsLimit, + DefaultValue: uint(10000), + }, + { + Name: "default-transactions-limit", + Usage: "Default cap on the amount of transactions included in a single getTransactions response", + ConfigKey: &cfg.DefaultTransactionsLimit, + DefaultValue: uint(100), + Validate: func(co *ConfigOption) error { + if cfg.DefaultTransactionsLimit > cfg.MaxTransactionsLimit { + return fmt.Errorf( + "default-transactions-limit (%v) cannot exceed max-transactions-limit (%v)", + cfg.DefaultTransactionsLimit, + cfg.MaxTransactionsLimit, + ) + } + return nil + }, + }, { Name: "max-healthy-ledger-latency", Usage: "maximum ledger latency (i.e. time elapsed since the last known ledger closing time) considered to be healthy" + diff --git a/cmd/soroban-rpc/internal/methods/get_transactions.go b/cmd/soroban-rpc/internal/methods/get_transactions.go index e5b764a6..4a78bee6 100644 --- a/cmd/soroban-rpc/internal/methods/get_transactions.go +++ b/cmd/soroban-rpc/internal/methods/get_transactions.go @@ -18,14 +18,6 @@ type TransactionsPaginationOptions struct { Limit uint `json:"limit,omitempty"` } -// Range defines a [Start, End] interval of ledgers. -type Range struct { - // Start defines the (inclusive) start of the range. - Start transactions.Cursor - // End defines the (inclusive) end of the range. - End transactions.Cursor -} - type GetTransactionsRequest struct { StartLedger uint32 `json:"startLedger"` EndLedger uint32 `json:"endLedger"`