Skip to content

Commit

Permalink
Move logging
Browse files Browse the repository at this point in the history
  • Loading branch information
hweawer committed Nov 28, 2024
1 parent ed88f53 commit 108074e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
9 changes: 8 additions & 1 deletion src/providers/http_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,14 @@ def _get(

for host in self.hosts:
try:
return self._get_without_fallbacks(host, endpoint, path_params, query_params, stream)
data = self._get_without_fallbacks(host, endpoint, path_params, query_params, stream)
logger.debug({
'msg': 'Get request',
'url': endpoint,
'data': f'{data}',
'host': f'{urlparse(host).netloc}',
})
return data
except Exception as e: # pylint: disable=W0703
errors.append(e)

Expand Down
29 changes: 4 additions & 25 deletions src/providers/keys/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,40 +57,19 @@ def _get_with_blockstamp(self, url: str, blockstamp: BlockStamp, params: dict |
@list_of_dataclasses(LidoKey.from_response)
def get_used_lido_keys(self, blockstamp: BlockStamp) -> list[dict]:
"""Docs: https://keys-api.lido.fi/api/static/index.html#/keys/KeysController_get"""
url = self.USED_KEYS
used_lido_keys = cast(list[dict], self._get_with_blockstamp(url, blockstamp))
logger.debug({
'msg': '[KEYS API] Used lido keys',
'url': url,
'used_keys': f'{used_lido_keys}',
})
return used_lido_keys
return cast(list[dict], self._get_with_blockstamp(self.USED_KEYS, blockstamp))

@lru_cache(maxsize=1)
def get_module_operators_keys(self, module_address: StakingModuleAddress, blockstamp: BlockStamp) -> dict:
"""
Docs: https://keys-api.lido.fi/api/static/index.html#/operators-keys/SRModulesOperatorsKeysController_getOperatorsKeys
"""
url = self.MODULE_OPERATORS_KEYS.format(module_address)
module_operators_keys = cast(dict, self._get_with_blockstamp(url, blockstamp))
logger.debug({
'msg': '[KEYS API] Module operator keys',
'url': url,
'module_operator_keys': f'{module_operators_keys}',
})
return module_operators_keys
return cast(dict, self._get_with_blockstamp(self.MODULE_OPERATORS_KEYS.format(module_address), blockstamp))

def get_status(self) -> KeysApiStatus:
"""Docs: https://keys-api.lido.fi/api/static/index.html#/status/StatusController_get"""
url = self.STATUS
data, _ = self._get(url)
keys_api_status = KeysApiStatus.from_response(**cast(dict, data))
logger.debug({
'msg': '[KEYS API] Status',
'url': url,
'keys_api_status': f'{keys_api_status}',
})
return keys_api_status
data, _ = self._get(self.STATUS)
return KeysApiStatus.from_response(**cast(dict, data))

def _get_chain_id_with_provider(self, provider_index: int) -> int:
data, _ = self._get_without_fallbacks(self.hosts[provider_index], self.STATUS)
Expand Down

0 comments on commit 108074e

Please sign in to comment.