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 {
899
899
logger : Logger ,
900
900
block_nums : Vec < BlockNumber > ,
901
901
) -> impl Stream < Item = BlockPtr , Error = Error > + Send {
902
- let web3 = self . web3 . clone ( ) ;
902
+ let alloy = self . alloy . clone ( ) ;
903
903
904
904
stream:: iter_ok :: < _ , Error > ( block_nums. into_iter ( ) . map ( move |block_num| {
905
- let web3 = web3 . clone ( ) ;
905
+ let alloy = alloy . clone ( ) ;
906
906
retry ( format ! ( "load block ptr {}" , block_num) , & logger)
907
907
. redact_log_urls ( true )
908
908
. when ( |res| !res. is_ok ( ) && !detect_null_block ( res) )
909
909
. no_limit ( )
910
910
. timeout_secs ( ENV_VARS . json_rpc_timeout . as_secs ( ) )
911
911
. run ( move || {
912
- let web3 = web3 . clone ( ) ;
912
+ let alloy = alloy . cheap_clone ( ) ;
913
913
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
+ ) )
918
918
. await ?;
919
919
920
920
block. ok_or_else ( || {
@@ -935,7 +935,7 @@ impl EthereumAdapter {
935
935
} ) )
936
936
. buffered ( ENV_VARS . block_batch_size )
937
937
. filter_map ( |b| b)
938
- . map ( |b| b . into ( ) )
938
+ . map ( |b| BlockPtr :: from ( ( b . header . hash , b . header . number as i32 ) ) )
939
939
}
940
940
941
941
/// 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 {
241
241
}
242
242
}
243
243
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
+
244
253
impl From < ( Vec < u8 > , u64 ) > for BlockPtr {
245
254
fn from ( ( bytes, number) : ( Vec < u8 > , u64 ) ) -> Self {
246
255
let number = i32:: try_from ( number) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments