Skip to content

Commit

Permalink
Merge pull request #48 from Mai-Te-Pora/bugfix/error-19
Browse files Browse the repository at this point in the history
Bugfix/error 19
  • Loading branch information
switcheolytics committed Mar 22, 2021
2 parents 40d33d0 + 1e4e1d8 commit 2ccf5e8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tradehub/decentralized_client.py
Expand Up @@ -349,7 +349,8 @@ def tradehub_get_request(self, path: str, params: dict = None):
req = Request(api_url=self.active_sentry_uri, timeout=2).get(path=path, params=params)
return req
except (ValueError, ConnectionError, HTTPError, Timeout):
self.active_sentry_api_list.remove(self.active_sentry_uri)
if self.active_sentry_uri in self.active_sentry_api_list:
self.active_sentry_api_list.remove(self.active_sentry_uri)
if not self.active_sentry_api_list and not self.BYPASS_NETWORK_CRAWLER:
self.validator_crawler_mp()
self.sentry_status_request()
Expand All @@ -373,10 +374,11 @@ def tradehub_post_request(self, path: str, data: dict = None, json_data: dict =
:return: Dictionary of the return request based on the network path sent.
"""
try:
req = Request(api_url=self.active_sentry_uri, timeout=2).post(path=path, data=data, json_data=json_data, params=params)
req = Request(api_url=self.active_sentry_uri, timeout=30).post(path=path, data=data, json_data=json_data, params=params)
return req
except (ValueError, ConnectionError, HTTPError, Timeout):
self.active_sentry_api_list.remove(self.active_sentry_uri)
except (ValueError, ConnectionError, HTTPError, Timeout) as e:
if self.active_sentry_uri in self.active_sentry_api_list:
self.active_sentry_api_list.remove(self.active_sentry_uri)
if not self.active_sentry_api_list and not self.BYPASS_NETWORK_CRAWLER:
self.validator_crawler_mp()
self.sentry_status_request()
Expand Down
10 changes: 10 additions & 0 deletions tradehub/transactions.py
Expand Up @@ -53,6 +53,16 @@ def __init__(self, wallet: Wallet, trusted_ips: list = None, trusted_uris: list
self.gas = "100000000000" # Need to automate
self.tokens = self.get_token_details()

def update_account_details(self) -> None:
"""
Triggers an update to fetch current sequence number.
:return: None
"""
self.account_blockchain_dict = self.get_account_details()
self.account_nbr = self.account_blockchain_dict["result"]["value"]["account_number"]
self.account_sequence_nbr = self.account_blockchain_dict["result"]["value"]["sequence"]

def get_account_details(self):
"""
Retrieve Wallet account details required for submitting transactions on Tradehub.
Expand Down
11 changes: 11 additions & 0 deletions tradehub/websocket_client.py
Expand Up @@ -942,6 +942,17 @@ async def send(self, data: dict):
"""
await self._websocket.send(json.dumps(data))

def open(self) -> bool:
"""
Check if the connection is open.
:return: Bool
"""
if not self._websocket:
return False

return self._websocket.open

async def disconnect(self):
"""
Safely close the websocket connection.
Expand Down

0 comments on commit 2ccf5e8

Please sign in to comment.