@@ -100,7 +100,7 @@ pub async fn probe_all_providers(config: &ForeignChainsConfig) -> ProbeReport {
100100 . map ( |( chain, chain_config) | async move {
101101 match chain {
102102 ForeignChain :: Starknet => {
103- probe_chain ( chain, chain_config, |provider, _ | {
103+ probe_chain ( chain, chain_config, |provider| {
104104 Ok ( StarknetInspector :: new ( prepare_jsonrpc ( provider) ?) )
105105 } )
106106 . await
@@ -112,13 +112,14 @@ pub async fn probe_all_providers(config: &ForeignChainsConfig) -> ProbeReport {
112112 ForeignChain :: HyperEvm => probe_evm :: < HyperEvm > ( chain, chain_config) . await ,
113113 ForeignChain :: Polygon => probe_evm :: < Polygon > ( chain, chain_config) . await ,
114114 ForeignChain :: Bitcoin => {
115- probe_chain ( chain, chain_config, |provider, _ | {
115+ probe_chain ( chain, chain_config, |provider| {
116116 Ok ( BitcoinInspector :: new ( prepare_jsonrpc ( provider) ?) )
117117 } )
118118 . await
119119 }
120120 ForeignChain :: Aptos => {
121- probe_chain ( chain, chain_config, |provider, timeout| {
121+ let timeout = Duration :: from_secs ( chain_config. timeout_sec . get ( ) ) ;
122+ probe_chain ( chain, chain_config, move |provider| {
122123 let ( url, auth_header) = prepare_aptos ( provider) ?;
123124 Ok ( AptosInspector :: new ( ReqwestAptosClient :: new (
124125 url,
@@ -129,7 +130,8 @@ pub async fn probe_all_providers(config: &ForeignChainsConfig) -> ProbeReport {
129130 . await
130131 }
131132 ForeignChain :: Sui => {
132- probe_chain ( chain, chain_config, |provider, timeout| {
133+ let timeout = Duration :: from_secs ( chain_config. timeout_sec . get ( ) ) ;
134+ probe_chain ( chain, chain_config, move |provider| {
133135 Ok ( SuiInspector :: new ( prepare_sui ( provider, timeout) ?) )
134136 } )
135137 . await
@@ -148,18 +150,18 @@ async fn probe_evm<Chain>(chain: ForeignChain, config: &ForeignChainConfig) -> V
148150where
149151 Chain : EvmChain + Clone + Send + Sync + ' static ,
150152{
151- probe_chain ( chain, config, |provider, _ | {
153+ probe_chain ( chain, config, |provider| {
152154 Ok ( EvmInspector :: < _ , Chain > :: new ( prepare_jsonrpc ( provider) ?) )
153155 } )
154156 . await
155157}
156158
157- /// `new_inspector` is handed the same deadline the probe gives each attempt, for the clients that
158- /// carry their own .
159+ // TODO(#4043): take the inspectors as a dependency instead, so that building a client from
160+ // config, and the deadline it is built with, live outside the probe .
159161async fn probe_chain < I > (
160162 chain : ForeignChain ,
161163 config : & ForeignChainConfig ,
162- new_inspector : impl Fn ( & ForeignChainProviderConfig , Duration ) -> anyhow:: Result < I > ,
164+ new_inspector : impl Fn ( & ForeignChainProviderConfig ) -> anyhow:: Result < I > ,
163165) -> Vec < ProviderHealth >
164166where
165167 I : foreign_chain_inspector:: NetworkFingerprintInspector + Clone + Send + Sync + ' static ,
@@ -169,12 +171,11 @@ where
169171 } ;
170172 let expected = I :: canonical_fingerprint ( expected) ;
171173
172- let timeout = Duration :: from_secs ( config. timeout_sec . get ( ) ) ;
173174 let mut inspectors = Vec :: new ( ) ;
174175 let mut rows = Vec :: new ( ) ;
175176 for ( name, provider) in config. providers . iter ( ) {
176177 let provider_id = ProviderId ( name. as_str ( ) . to_owned ( ) ) ;
177- match new_inspector ( provider, timeout ) {
178+ match new_inspector ( provider) {
178179 Ok ( inspector) => inspectors. push ( ( provider_id, inspector) ) ,
179180 Err ( error) => rows. push ( ProviderHealth {
180181 chain,
@@ -188,6 +189,7 @@ where
188189 return rows;
189190 } ;
190191
192+ let timeout = Duration :: from_secs ( config. timeout_sec . get ( ) ) ;
191193 let fingerprints = FanOut :: new ( inspectors)
192194 . network_fingerprints ( timeout, config. max_retries )
193195 . await ;
0 commit comments