File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed
Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -899,22 +899,22 @@ impl EthereumAdapter {
899899 logger : Logger ,
900900 block_nums : Vec < BlockNumber > ,
901901 ) -> impl Stream < Item = BlockPtr , Error = Error > + Send {
902- let web3 = self . web3 . clone ( ) ;
902+ let alloy = self . alloy . clone ( ) ;
903903
904904 stream:: iter_ok :: < _ , Error > ( block_nums. into_iter ( ) . map ( move |block_num| {
905- let web3 = web3 . clone ( ) ;
905+ let alloy = alloy . clone ( ) ;
906906 retry ( format ! ( "load block ptr {}" , block_num) , & logger)
907907 . redact_log_urls ( true )
908908 . when ( |res| !res. is_ok ( ) && !detect_null_block ( res) )
909909 . no_limit ( )
910910 . timeout_secs ( ENV_VARS . json_rpc_timeout . as_secs ( ) )
911911 . run ( move || {
912- let web3 = web3 . clone ( ) ;
912+ let alloy = alloy . cheap_clone ( ) ;
913913 async move {
914- let block = web3
915- . eth ( )
916- . block ( BlockId :: Number ( Web3BlockNumber :: Number ( block_num. into ( ) ) ) )
917- . boxed ( )
914+ let block = alloy
915+ . get_block_by_number ( alloy_rpc_types :: BlockNumberOrTag :: Number (
916+ block_num as u64 ,
917+ ) )
918918 . await ?;
919919
920920 block. ok_or_else ( || {
@@ -935,7 +935,7 @@ impl EthereumAdapter {
935935 } ) )
936936 . buffered ( ENV_VARS . block_batch_size )
937937 . filter_map ( |b| b)
938- . map ( |b| b . into ( ) )
938+ . map ( |b| BlockPtr :: from ( ( b . header . hash , b . header . number as i32 ) ) )
939939 }
940940
941941 /// Check if `block_ptr` refers to a block that is on the main chain, according to the Ethereum
Original file line number Diff line number Diff line change @@ -241,6 +241,15 @@ impl From<(H256, i32)> for BlockPtr {
241241 }
242242}
243243
244+ impl From < ( alloy:: primitives:: B256 , i32 ) > for BlockPtr {
245+ fn from ( ( hash, number) : ( alloy:: primitives:: B256 , i32 ) ) -> BlockPtr {
246+ BlockPtr {
247+ hash : hash. into ( ) ,
248+ number,
249+ }
250+ }
251+ }
252+
244253impl From < ( Vec < u8 > , u64 ) > for BlockPtr {
245254 fn from ( ( bytes, number) : ( Vec < u8 > , u64 ) ) -> Self {
246255 let number = i32:: try_from ( number) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments