File tree Expand file tree Collapse file tree 3 files changed +16
-19
lines changed
Expand file tree Collapse file tree 3 files changed +16
-19
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ use graph::{
2626 petgraph:: { self , graphmap:: GraphMap } ,
2727} ;
2828
29+ use graph:: blockchain:: BlockPtr ;
30+
2931const COMBINED_FILTER_TYPE_URL : & str =
3032 "type.googleapis.com/sf.ethereum.transform.v1.CombinedFilter" ;
3133
@@ -1083,10 +1085,7 @@ pub trait EthereumAdapter: Send + Sync + 'static {
10831085 async fn latest_block ( & self , logger : & Logger ) -> Result < LightEthereumBlock , bc:: IngestorError > ;
10841086
10851087 /// Get the latest block, with only the header and transaction hashes.
1086- async fn latest_block_header (
1087- & self ,
1088- logger : & Logger ,
1089- ) -> Result < web3:: types:: Block < H256 > , bc:: IngestorError > ;
1088+ async fn latest_block_header ( & self , logger : & Logger ) -> Result < BlockPtr , bc:: IngestorError > ;
10901089
10911090 async fn load_block (
10921091 & self ,
Original file line number Diff line number Diff line change @@ -1288,26 +1288,27 @@ impl EthereumAdapterTrait for EthereumAdapter {
12881288 Ok ( ident)
12891289 }
12901290
1291- async fn latest_block_header (
1292- & self ,
1293- logger : & Logger ,
1294- ) -> Result < web3:: types:: Block < H256 > , IngestorError > {
1295- let web3 = self . web3 . clone ( ) ;
1291+ async fn latest_block_header ( & self , logger : & Logger ) -> Result < BlockPtr , IngestorError > {
1292+ let alloy = self . alloy . clone ( ) ;
12961293 retry ( "eth_getBlockByNumber(latest) no txs RPC call" , logger)
12971294 . redact_log_urls ( true )
12981295 . no_limit ( )
12991296 . timeout_secs ( ENV_VARS . json_rpc_timeout . as_secs ( ) )
13001297 . run ( move || {
1301- let web3 = web3 . cheap_clone ( ) ;
1298+ let alloy = alloy . cheap_clone ( ) ;
13021299 async move {
1303- let block_opt = web3
1304- . eth ( )
1305- . block ( Web3BlockNumber :: Latest . into ( ) )
1300+ let block_opt = alloy
1301+ . get_block_by_number ( alloy:: rpc:: types:: BlockNumberOrTag :: Latest )
13061302 . await
13071303 . map_err ( |e| anyhow ! ( "could not get latest block from Ethereum: {}" , e) ) ?;
13081304
1309- block_opt
1310- . ok_or_else ( || anyhow ! ( "no latest block returned from Ethereum" ) . into ( ) )
1305+ let block = block_opt
1306+ . ok_or_else ( || anyhow ! ( "no latest block returned from Ethereum" ) ) ?;
1307+
1308+ Ok ( BlockPtr :: from ( (
1309+ block. header . hash ,
1310+ block. header . number as i32 ,
1311+ ) ) )
13111312 }
13121313 } )
13131314 . map_err ( move |e| {
Original file line number Diff line number Diff line change @@ -206,10 +206,7 @@ impl PollingBlockIngestor {
206206 logger : & Logger ,
207207 eth_adapter : & Arc < EthereumAdapter > ,
208208 ) -> Result < BlockPtr , IngestorError > {
209- eth_adapter
210- . latest_block_header ( & logger)
211- . await
212- . map ( |block| block. into ( ) )
209+ eth_adapter. latest_block_header ( & logger) . await
213210 }
214211
215212 async fn eth_adapter ( & self ) -> anyhow:: Result < Arc < EthereumAdapter > > {
You can’t perform that action at this time.
0 commit comments