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 @@ -1288,26 +1288,27 @@ impl EthereumAdapterTrait for EthereumAdapter {
1288
1288
Ok ( ident)
1289
1289
}
1290
1290
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 ( ) ;
1296
1293
retry ( "eth_getBlockByNumber(latest) no txs RPC call" , logger)
1297
1294
. redact_log_urls ( true )
1298
1295
. no_limit ( )
1299
1296
. timeout_secs ( ENV_VARS . json_rpc_timeout . as_secs ( ) )
1300
1297
. run ( move || {
1301
- let web3 = web3 . cheap_clone ( ) ;
1298
+ let alloy = alloy . cheap_clone ( ) ;
1302
1299
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 )
1306
1302
. await
1307
1303
. map_err ( |e| anyhow ! ( "could not get latest block from Ethereum: {}" , e) ) ?;
1308
1304
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
+ ) ) )
1311
1312
}
1312
1313
} )
1313
1314
. 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