diff --git a/xrpl/rpc/config.go b/xrpl/rpc/config.go index 281324c3..734cb9aa 100644 --- a/xrpl/rpc/config.go +++ b/xrpl/rpc/config.go @@ -43,6 +43,20 @@ func WithHTTPClient(cl HTTPClient) ConfigOpt { } } +// WithMaxRetries returns a ConfigOpt that sets the maximum number of retries. +func WithMaxRetries(maxRetries int) ConfigOpt { + return func(c *Config) { + c.maxRetries = maxRetries + } +} + +// WithRetryDelay returns a ConfigOpt that sets the delay between retry attempts. +func WithRetryDelay(retryDelay time.Duration) ConfigOpt { + return func(c *Config) { + c.retryDelay = retryDelay + } +} + // WithMaxFeeXRP returns a ConfigOpt that sets the maximum fee in XRP. func WithMaxFeeXRP(maxFeeXRP float32) ConfigOpt { return func(c *Config) { diff --git a/xrpl/rpc/config_test.go b/xrpl/rpc/config_test.go index d04b38ed..5a4bfe62 100644 --- a/xrpl/rpc/config_test.go +++ b/xrpl/rpc/config_test.go @@ -85,3 +85,17 @@ func TestWithTimeout(t *testing.T) { require.Equal(t, timeOut, cfg.timeout) } + +func TestWithMaxRetries(t *testing.T) { + maxRetries := 5 + cfg, _ := NewClientConfig("http://s1.ripple.com:51234", WithMaxRetries(maxRetries)) + + require.Equal(t, maxRetries, cfg.maxRetries) +} + +func TestWithRetryDelay(t *testing.T) { + retryDelay := 2 * time.Second + cfg, _ := NewClientConfig("http://s1.ripple.com:51234", WithRetryDelay(retryDelay)) + + require.Equal(t, retryDelay, cfg.retryDelay) +}