Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Commit 2d0926d

Browse files
authored
Merge pull request #40 from semiotic-ai/aasseman/fix-single-network
fix: support single-network mode
2 parents 5c22725 + beae50e commit 2d0926d

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

autoagora_processor/indexer_api.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import backoff
88
from gql import Client, gql
9+
from gql.transport.exceptions import TransportQueryError
910
from gql.transport.requests import RequestsHTTPTransport
1011
from requests import RequestException
1112

@@ -42,9 +43,32 @@ def get_network_allocated_subgraphs(network: str) -> Set[str]:
4243

4344

4445
def get_allocated_subgraphs() -> Set[str]:
45-
"""Get the indexer's subgraph allocations for all Graph networks."""
46+
"""
47+
Get the indexer's subgraph allocations for all Graph networks.
48+
49+
Will try for both mainnet and arbitrum-one networks. If one of them fails, it
50+
will ignore it (happens if the indexer-agent is in single network mode).
51+
If both fail, it will raise the exception.
52+
"""
4653

4754
networks = ("mainnet", "arbitrum-one")
48-
results = map(get_network_allocated_subgraphs, networks)
55+
results = []
56+
57+
for network in networks:
58+
try:
59+
results += [get_network_allocated_subgraphs(network)]
60+
except TransportQueryError:
61+
logging.info(
62+
f"Failed to get indexer allocations for network '{network}'. Ignoring."
63+
)
64+
results += [None]
65+
66+
if all(r is None for r in results):
67+
raise RuntimeError(
68+
f"Failed to query indexer allocations for all Graph networks: {networks}."
69+
)
70+
71+
# Replace None's with empty set
72+
results = [r if r is not None else set() for r in results]
4973

5074
return set.union(*results)

0 commit comments

Comments
 (0)