File tree Expand file tree Collapse file tree 2 files changed +23
-35
lines changed Expand file tree Collapse file tree 2 files changed +23
-35
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ use prost_types::Any;
17
17
use std:: cmp;
18
18
use std:: collections:: { HashMap , HashSet } ;
19
19
use std:: fmt;
20
- use std:: marker:: Unpin ;
21
20
use thiserror:: Error ;
22
21
use tiny_keccak:: keccak256;
23
22
use web3:: types:: { Address , Log , H256 } ;
@@ -1082,10 +1081,7 @@ pub trait EthereumAdapter: Send + Sync + 'static {
1082
1081
async fn net_identifiers ( & self ) -> Result < ChainIdentifier , Error > ;
1083
1082
1084
1083
/// Get the latest block, including full transactions.
1085
- fn latest_block (
1086
- & self ,
1087
- logger : & Logger ,
1088
- ) -> Box < dyn Future < Item = LightEthereumBlock , Error = bc:: IngestorError > + Send + Unpin > ;
1084
+ async fn latest_block ( & self , logger : & Logger ) -> Result < LightEthereumBlock , bc:: IngestorError > ;
1089
1085
1090
1086
/// Get the latest block, with only the header and transaction hashes.
1091
1087
async fn latest_block_header (
Original file line number Diff line number Diff line change @@ -1288,38 +1288,30 @@ impl EthereumAdapterTrait for EthereumAdapter {
1288
1288
. await
1289
1289
}
1290
1290
1291
- fn latest_block (
1292
- & self ,
1293
- logger : & Logger ,
1294
- ) -> Box < dyn Future < Item = LightEthereumBlock , Error = IngestorError > + Send + Unpin > {
1291
+ async fn latest_block ( & self , logger : & Logger ) -> Result < LightEthereumBlock , IngestorError > {
1295
1292
let web3 = self . web3 . clone ( ) ;
1296
- Box :: new (
1297
- retry ( "eth_getBlockByNumber(latest) with txs RPC call" , logger)
1298
- . redact_log_urls ( true )
1299
- . no_limit ( )
1300
- . timeout_secs ( ENV_VARS . json_rpc_timeout . as_secs ( ) )
1301
- . run ( move || {
1302
- let web3 = web3. cheap_clone ( ) ;
1303
- async move {
1304
- let block_opt = web3
1305
- . eth ( )
1306
- . block_with_txs ( Web3BlockNumber :: Latest . into ( ) )
1307
- . await
1308
- . map_err ( |e| {
1309
- anyhow ! ( "could not get latest block from Ethereum: {}" , e)
1310
- } ) ?;
1311
- block_opt
1312
- . ok_or_else ( || anyhow ! ( "no latest block returned from Ethereum" ) . into ( ) )
1313
- }
1314
- } )
1315
- . map_err ( move |e| {
1316
- e. into_inner ( ) . unwrap_or_else ( move || {
1317
- anyhow ! ( "Ethereum node took too long to return latest block" ) . into ( )
1318
- } )
1293
+ retry ( "eth_getBlockByNumber(latest) with txs RPC call" , logger)
1294
+ . redact_log_urls ( true )
1295
+ . no_limit ( )
1296
+ . timeout_secs ( ENV_VARS . json_rpc_timeout . as_secs ( ) )
1297
+ . run ( move || {
1298
+ let web3 = web3. cheap_clone ( ) ;
1299
+ async move {
1300
+ let block_opt = web3
1301
+ . eth ( )
1302
+ . block_with_txs ( Web3BlockNumber :: Latest . into ( ) )
1303
+ . await
1304
+ . map_err ( |e| anyhow ! ( "could not get latest block from Ethereum: {}" , e) ) ?;
1305
+ block_opt
1306
+ . ok_or_else ( || anyhow ! ( "no latest block returned from Ethereum" ) . into ( ) )
1307
+ }
1308
+ } )
1309
+ . map_err ( move |e| {
1310
+ e. into_inner ( ) . unwrap_or_else ( move || {
1311
+ anyhow ! ( "Ethereum node took too long to return latest block" ) . into ( )
1319
1312
} )
1320
- . boxed ( )
1321
- . compat ( ) ,
1322
- )
1313
+ } )
1314
+ . await
1323
1315
}
1324
1316
1325
1317
fn load_block (
You can’t perform that action at this time.
0 commit comments