Skip to content

Commit

Permalink
Return fresh data even if some rpc or rest servers error
Browse files Browse the repository at this point in the history
  • Loading branch information
pharr117 committed Sep 4, 2023
1 parent 65ca3fe commit b9ca1a1
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
MAINNET_DATA = []
TESTNET_DATA = []

SEMANTIC_VERSION_PATTERN = re.compile(r'(v\d+\.\d+\.\d+)')
SEMANTIC_VERSION_PATTERN = re.compile(r'(v\d+(?:\.\d+){0,2})')

# Explicit list of chains to pull data from
def get_chain_watch_env_var():
Expand Down Expand Up @@ -279,6 +279,7 @@ def fetch_data_for_network(network, network_type, repo_path):

err_output_data = {
"network": network,
"type": network_type,
"error": "insufficient data in Cosmos chain registry, consider a PR to cosmos/chain-registry",
"upgrade_found": False
}
Expand Down Expand Up @@ -306,13 +307,6 @@ def fetch_data_for_network(network, network_type, repo_path):
err_output_data["error"] = f"insufficient data in Cosmos chain registry, no healthy RPC servers for {network}. Consider a PR to cosmos/chain-registry"
return err_output_data

if len(healthy_rest_endpoints) == 0:
print(f"No healthy REST endpoints found for network {network} while searching through {len(rest_endpoints)} endpoints. Skipping...")
err_output_data["error"] = f"insufficient data in Cosmos chain registry, no healthy REST servers for {network}. Consider a PR to cosmos/chain-registry"
return err_output_data

print(f"Found {len(healthy_rest_endpoints)} rest endpoints and {len(healthy_rpc_endpoints)} rpc endpoints for {network}")

# Shuffle the healthy endpoints
shuffle(healthy_rpc_endpoints)
shuffle(healthy_rest_endpoints)
Expand All @@ -324,6 +318,15 @@ def fetch_data_for_network(network, network_type, repo_path):
rpc_server_used = rpc_endpoint['address']
break

if len(healthy_rest_endpoints) == 0:
print(f"No healthy REST endpoints found for network {network} while searching through {len(rest_endpoints)} endpoints. Skipping...")
err_output_data["error"] = f"insufficient data in Cosmos chain registry, no healthy REST servers for {network}. Consider a PR to cosmos/chain-registry"
err_output_data["latest_block_height"] = latest_block_height
err_output_data["rpc_server"] = rpc_server_used
return err_output_data

print(f"Found {len(healthy_rest_endpoints)} rest endpoints and {len(healthy_rpc_endpoints)} rpc endpoints for {network}")

# Check for active upgrade proposals
upgrade_block_height = None
upgrade_name = ""
Expand Down

0 comments on commit b9ca1a1

Please sign in to comment.