File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change 1+ use std:: time:: Duration ;
2+
13use alloy:: sol_types:: SolType ;
24use alloy:: {
35 network:: TransactionBuilder ,
@@ -7,8 +9,8 @@ use alloy::{
79 sol,
810 sol_types:: SolCall ,
911} ;
10-
1112use color_eyre:: { Result , eyre:: eyre} ;
13+ use tokio:: time:: sleep;
1214use tracing:: { debug, error} ;
1315
1416use crate :: config:: CONFIG ;
@@ -49,7 +51,22 @@ pub async fn valid_curio_provider(address: &str) -> Result<Option<String>> {
4951 . with_to ( miner_peer_id_contract)
5052 . with_input ( input) ;
5153
52- let response = rpc_provider. call ( tx) . await ?;
54+ let mut response = None ;
55+
56+ for attempt in 1 ..=3 {
57+ match rpc_provider. call ( tx. clone ( ) ) . await {
58+ Ok ( res) => {
59+ response = Some ( res) ;
60+ break ;
61+ }
62+ Err ( e) => {
63+ println ! ( "Attempt {attempt}/3 failed: {e} for address: {address}" ) ;
64+ sleep ( Duration :: from_secs ( 1 ) ) . await ;
65+ }
66+ }
67+ }
68+
69+ let response = response. ok_or_else ( || eyre ! ( "All 3 attempts failed for address {address}" ) ) ?;
5370
5471 let peer_data: PeerData = PeerData :: abi_decode ( response. as_ref ( ) ) ?;
5572
You can’t perform that action at this time.
0 commit comments