Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions xrpl/rpc/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 14 additions & 0 deletions xrpl/rpc/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Loading