diff --git a/proxy/endpoints.py b/proxy/endpoints.py index 51d2cce..ec2feb7 100644 --- a/proxy/endpoints.py +++ b/proxy/endpoints.py @@ -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 @@ -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: diff --git a/proxy/helper.py b/proxy/helper.py index ccc3609..bb21ad3 100644 --- a/proxy/helper.py +++ b/proxy/helper.py @@ -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