File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
src/aleph/web/controllers Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change 77from dataclasses import dataclass , asdict
88from typing import Dict , Optional
99from urllib .parse import urljoin
10+ from requests import HTTPError
1011
1112import aiohttp
1213from aiocache import cached
@@ -118,13 +119,16 @@ async def fetch_eth_height() -> Optional[int]:
118119 """Obtain the height of the Ethereum blockchain."""
119120 LOGGER .debug ("Fetching ETH height" )
120121 config = app ['config' ]
121-
122- if config .ethereum .enabled .value :
123- w3 = Web3 (Web3 .HTTPProvider (config .ethereum .api_url .value ))
124- return await asyncio .get_event_loop ().run_in_executor (
125- None , getattr , w3 .eth , 'block_number' )
126- else :
127- return None
122+
123+ try :
124+ if config .ethereum .enabled .value :
125+ w3 = Web3 (Web3 .HTTPProvider (config .ethereum .api_url .value ))
126+ return await asyncio .get_event_loop ().run_in_executor (
127+ None , getattr , w3 .eth , 'block_number' )
128+ else :
129+ return None
130+ except HTTPError :
131+ return - 1 # We got a boggus value!
128132
129133
130134async def get_metrics (shared_stats :dict ) -> Metrics :
You can’t perform that action at this time.
0 commit comments