@@ -5,6 +5,15 @@ use super::env::EnvVarParser;
55/// Default network status refetch interval in seconds
66const DEFAULT_NETWORK_STATUS_REFETCH_INTERVAL_S : u64 = 10 ;
77
8+ /// Default retry policy max retries
9+ const DEFAULT_RETRY_POLICY_MAX_RETRIES : u64 = 5 ;
10+
11+ /// Default retry policy total retry time
12+ const DEFAULT_RETRY_POLICY_TOTAL_RETRY_TIME : u64 = 60 ;
13+
14+ /// Default retry policy base
15+ const DEFAULT_RETRY_POLICY_BASE : f64 = 1.5 ;
16+
817#[ derive( Debug , Clone ) ]
918pub ( crate ) struct NetworkConfig {
1019 /// JSON-RPC Endpoint for Strata sequencer
@@ -16,11 +25,11 @@ pub(crate) struct NetworkConfig {
1625 /// Bundler health check URL (overrides `.env`)
1726 bundler_url : String ,
1827
19- /// Max retries in querying status
20- max_retries : u64 ,
28+ /// Max retries for status queries
29+ retry_policy_max_retries : u64 ,
2130
22- /// Total time in seconds to spend retrying
23- total_retry_time : u64 ,
31+ /// Total time in seconds to spend retrying status queries
32+ retry_policy_total_time_s : u64 ,
2433
2534 /// Network status refetch interval in seconds
2635 status_refetch_interval_s : u64 ,
@@ -37,9 +46,10 @@ impl NetworkConfig {
3746 let bundler_url = String :: parse_env_var ( "BUNDLER_URL" )
3847 . unwrap_or_else ( || "http://localhost:8434" . to_string ( ) ) ;
3948
40- let max_retries = u64:: parse_env_var ( "MAX_STATUS_RETRIES" ) . unwrap_or ( 5 ) ;
41-
42- let total_retry_time = u64:: parse_env_var ( "TOTAL_RETRY_TIME" ) . unwrap_or ( 60 ) ;
49+ let retry_policy_max_retries = u64:: parse_env_var ( "NETWORK_STATUS_MAX_RETRIES" )
50+ . unwrap_or ( DEFAULT_RETRY_POLICY_MAX_RETRIES ) ;
51+ let retry_policy_total_time_s = u64:: parse_env_var ( "NETWORK_STATUS_TOTAL_RETRY_TIME_S" )
52+ . unwrap_or ( DEFAULT_RETRY_POLICY_TOTAL_RETRY_TIME ) ;
4353
4454 let status_refetch_interval_s = u64:: parse_env_var ( "NETWORK_STATUS_REFETCH_INTERVAL_S" )
4555 . unwrap_or ( DEFAULT_NETWORK_STATUS_REFETCH_INTERVAL_S ) ;
@@ -50,8 +60,8 @@ impl NetworkConfig {
5060 sequencer_url,
5161 rpc_url,
5262 bundler_url,
53- max_retries ,
54- total_retry_time ,
63+ retry_policy_max_retries ,
64+ retry_policy_total_time_s ,
5565 status_refetch_interval_s,
5666 }
5767 }
@@ -71,18 +81,26 @@ impl NetworkConfig {
7181 & self . bundler_url
7282 }
7383
74- /// Getter for `max_retries `
75- pub ( crate ) fn max_retries ( & self ) -> u64 {
76- self . max_retries
84+ /// Getter for `status_refetch_interval_s `
85+ pub ( crate ) fn status_refetch_interval ( & self ) -> u64 {
86+ self . status_refetch_interval_s
7787 }
7888
79- /// Getter for `total_retry_time`
80- pub ( crate ) fn total_retry_time ( & self ) -> u64 {
81- self . total_retry_time
89+ /// Retry policy for sequencer status queries
90+ pub ( crate ) fn sequencer_retry_policy ( & self ) -> crate :: utils:: retry_policy:: ExponentialBackoff {
91+ crate :: utils:: retry_policy:: ExponentialBackoff :: new (
92+ self . retry_policy_max_retries ,
93+ self . retry_policy_total_time_s ,
94+ DEFAULT_RETRY_POLICY_BASE ,
95+ )
8296 }
8397
84- /// Getter for `status_refetch_interval_s`
85- pub ( crate ) fn status_refetch_interval ( & self ) -> u64 {
86- self . status_refetch_interval_s
98+ /// Retry policy for RPC endpoint status queries
99+ pub ( crate ) fn rpc_retry_policy ( & self ) -> crate :: utils:: retry_policy:: ExponentialBackoff {
100+ crate :: utils:: retry_policy:: ExponentialBackoff :: new (
101+ self . retry_policy_max_retries ,
102+ self . retry_policy_total_time_s ,
103+ DEFAULT_RETRY_POLICY_BASE ,
104+ )
87105 }
88106}
0 commit comments