Skip to content

Commit

Permalink
Merge pull request #54 from skalenetwork/filter-out-of-sync-nodes
Browse files Browse the repository at this point in the history
Update endpoint filtering logic
  • Loading branch information
dmytrotkk authored Aug 9, 2023
2 parents 6f56806 + 485a11b commit bb30d5b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions proxy/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _format_nodes(self, nodes):
if not url_ok(http_endpoint):
logger.warning(f'{http_endpoint} is not accesible, removing from the list')
continue
if not is_node_out_of_sync(node['block_ts'], max_ts):
if is_node_out_of_sync(node['block_ts'], max_ts):
logger.warning(f'{http_endpoint} ts: {node["block_ts"]}, max ts for chain: \
{max_ts}, allowed timestamp diff: {ALLOWED_TIMESTAMP_DIFF}')
continue
Expand All @@ -93,7 +93,7 @@ def url_ok(url) -> bool:


def is_node_out_of_sync(ts: int, compare_ts: int) -> bool:
return abs(compare_ts - ts) < ALLOWED_TIMESTAMP_DIFF
return abs(compare_ts - ts) > ALLOWED_TIMESTAMP_DIFF


def get_block_ts(http_endpoint: str) -> int:
Expand Down
4 changes: 3 additions & 1 deletion proxy/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ def post_request(url, json, cookies=None):

def make_rpc_call(http_endpoint, method, params=None):
params = params or []
return post_request(
resp = post_request(
http_endpoint,
json={"jsonrpc": "2.0", "method": method, "params": params, "id": 1}
)
if resp.status_code == 200:
return resp

0 comments on commit bb30d5b

Please sign in to comment.