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::{
26
26
petgraph:: { self , graphmap:: GraphMap } ,
27
27
} ;
28
28
29
+ use graph:: blockchain:: BlockPtr ;
30
+
29
31
const COMBINED_FILTER_TYPE_URL : & str =
30
32
"type.googleapis.com/sf.ethereum.transform.v1.CombinedFilter" ;
31
33
@@ -1083,10 +1085,7 @@ pub trait EthereumAdapter: Send + Sync + 'static {
1083
1085
async fn latest_block ( & self , logger : & Logger ) -> Result < LightEthereumBlock , bc:: IngestorError > ;
1084
1086
1085
1087
/// 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 > ;
1090
1089
1091
1090
async fn load_block (
1092
1091
& self ,
Original file line number Diff line number Diff line change @@ -1303,26 +1303,27 @@ impl EthereumAdapterTrait for EthereumAdapter {
1303
1303
Ok ( ident)
1304
1304
}
1305
1305
1306
- async fn latest_block_header (
1307
- & self ,
1308
- logger : & Logger ,
1309
- ) -> Result < web3:: types:: Block < H256 > , IngestorError > {
1310
- let web3 = self . web3 . clone ( ) ;
1306
+ async fn latest_block_header ( & self , logger : & Logger ) -> Result < BlockPtr , IngestorError > {
1307
+ let alloy = self . alloy . clone ( ) ;
1311
1308
retry ( "eth_getBlockByNumber(latest) no txs RPC call" , logger)
1312
1309
. redact_log_urls ( true )
1313
1310
. no_limit ( )
1314
1311
. timeout_secs ( ENV_VARS . json_rpc_timeout . as_secs ( ) )
1315
1312
. run ( move || {
1316
- let web3 = web3 . cheap_clone ( ) ;
1313
+ let alloy = alloy . cheap_clone ( ) ;
1317
1314
async move {
1318
- let block_opt = web3
1319
- . eth ( )
1320
- . block ( Web3BlockNumber :: Latest . into ( ) )
1315
+ let block_opt = alloy
1316
+ . get_block_by_number ( alloy:: rpc:: types:: BlockNumberOrTag :: Latest )
1321
1317
. await
1322
1318
. map_err ( |e| anyhow ! ( "could not get latest block from Ethereum: {}" , e) ) ?;
1323
1319
1324
- block_opt
1325
- . ok_or_else ( || anyhow ! ( "no latest block returned from Ethereum" ) . into ( ) )
1320
+ let block = block_opt
1321
+ . ok_or_else ( || anyhow ! ( "no latest block returned from Ethereum" ) ) ?;
1322
+
1323
+ Ok ( BlockPtr :: from ( (
1324
+ block. header . hash ,
1325
+ block. header . number as i32 ,
1326
+ ) ) )
1326
1327
}
1327
1328
} )
1328
1329
. map_err ( move |e| {
Original file line number Diff line number Diff line change @@ -206,10 +206,7 @@ impl PollingBlockIngestor {
206
206
logger : & Logger ,
207
207
eth_adapter : & Arc < EthereumAdapter > ,
208
208
) -> 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
213
210
}
214
211
215
212
async fn eth_adapter ( & self ) -> anyhow:: Result < Arc < EthereumAdapter > > {
You can’t perform that action at this time.
0 commit comments