@@ -72,10 +72,8 @@ impl<N: Network> SafeProvider<N> {
7272 number : BlockNumberOrTag ,
7373 ) -> Result < Option < N :: BlockResponse > , RpcError < TransportErrorKind > > {
7474 info ! ( "eth_getBlockByNumber called" ) ;
75- let provider = self . provider . clone ( ) ;
76- let result = self
77- . retry_with_total_timeout ( || async { provider. get_block_by_number ( number) . await } )
78- . await ;
75+ let operation = async || self . provider . get_block_by_number ( number) . await ;
76+ let result = self . retry_with_total_timeout ( operation) . await ;
7977 if let Err ( e) = & result {
8078 error ! ( error = %e, "eth_getByBlockNumber failed" ) ;
8179 }
@@ -109,10 +107,8 @@ impl<N: Network> SafeProvider<N> {
109107 hash : alloy:: primitives:: BlockHash ,
110108 ) -> Result < Option < N :: BlockResponse > , RpcError < TransportErrorKind > > {
111109 info ! ( "eth_getBlockByHash called" ) ;
112- let provider = self . provider . clone ( ) ;
113- let result = self
114- . retry_with_total_timeout ( || async { provider. get_block_by_hash ( hash) . await } )
115- . await ;
110+ let operation = async || self . provider . get_block_by_hash ( hash) . await ;
111+ let result = self . retry_with_total_timeout ( operation) . await ;
116112 if let Err ( e) = & result {
117113 error ! ( error = %e, "eth_getBlockByHash failed" ) ;
118114 }
@@ -130,9 +126,8 @@ impl<N: Network> SafeProvider<N> {
130126 filter : & Filter ,
131127 ) -> Result < Vec < Log > , RpcError < TransportErrorKind > > {
132128 info ! ( "eth_getLogs called" ) ;
133- let provider = self . provider . clone ( ) ;
134- let result =
135- self . retry_with_total_timeout ( || async { provider. get_logs ( filter) . await } ) . await ;
129+ let operation = || self . provider . get_logs ( filter) ;
130+ let result = self . retry_with_total_timeout ( operation) . await ;
136131 if let Err ( e) = & result {
137132 error ! ( error = %e, "eth_getLogs failed" ) ;
138133 }
0 commit comments