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;
1717use std:: cmp;
1818use std:: collections:: { HashMap , HashSet } ;
1919use std:: fmt;
20- use std:: marker:: Unpin ;
2120use thiserror:: Error ;
2221use tiny_keccak:: keccak256;
2322use web3:: types:: { Address , Log , H256 } ;
@@ -1082,10 +1081,7 @@ pub trait EthereumAdapter: Send + Sync + 'static {
10821081 async fn net_identifiers ( & self ) -> Result < ChainIdentifier , Error > ;
10831082
10841083 /// 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 > ;
10891085
10901086 /// Get the latest block, with only the header and transaction hashes.
10911087 async fn latest_block_header (
Original file line number Diff line number Diff line change @@ -1288,38 +1288,30 @@ impl EthereumAdapterTrait for EthereumAdapter {
12881288 . await
12891289 }
12901290
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 > {
12951292 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 ( )
13191312 } )
1320- . boxed ( )
1321- . compat ( ) ,
1322- )
1313+ } )
1314+ . await
13231315 }
13241316
13251317 fn load_block (
You can’t perform that action at this time.
0 commit comments