Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to allocate on network subgraph #339

Merged
merged 1 commit into from
Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/indexer-agent/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Agent {
indexer: Indexer
network: Network
networkSubgraph: NetworkSubgraph
allocateOnNetworkSubgraph: boolean
registerIndexer: boolean
offchainSubgraphs: SubgraphDeploymentID[]
receiptCollector: ReceiptCollector
Expand All @@ -69,6 +70,7 @@ class Agent {
indexer: Indexer,
network: Network,
networkSubgraph: NetworkSubgraph,
allocateOnNetworkSubgraph: boolean,
registerIndexer: boolean,
offchainSubgraphs: SubgraphDeploymentID[],
receiptCollector: ReceiptCollector,
Expand All @@ -78,6 +80,7 @@ class Agent {
this.indexer = indexer
this.network = network
this.networkSubgraph = networkSubgraph
this.allocateOnNetworkSubgraph = allocateOnNetworkSubgraph
this.registerIndexer = registerIndexer
this.offchainSubgraphs = offchainSubgraphs
this.receiptCollector = receiptCollector
Expand Down Expand Up @@ -580,8 +583,11 @@ class Agent {
...activeAllocations.map(allocation => allocation.subgraphDeployment.id),
])

// Ensure the network subgraph is never allocated towards
if (this.networkSubgraph.deployment?.id.bytes32) {
// Ensure the network subgraph is never allocated towards unless explicitly allowed
if (
!this.allocateOnNetworkSubgraph &&
this.networkSubgraph.deployment?.id.bytes32
) {
const networkSubgraphDeploymentId = this.networkSubgraph.deployment.id
targetDeployments = targetDeployments.filter(
deployment =>
Expand Down Expand Up @@ -919,6 +925,7 @@ export const startAgent = async (config: AgentConfig): Promise<Agent> => {
config.indexer,
config.network,
config.networkSubgraph,
config.allocateOnNetworkSubgraph,
config.registerIndexer,
config.offchainSubgraphs,
config.receiptCollector,
Expand Down
7 changes: 7 additions & 0 deletions packages/indexer-agent/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ export default {
type: 'string',
group: 'Network Subgraph',
})
.option('allocate-on-network-subgraph', {
description: 'Whether to allocate to the network subgraph',
type: 'boolean',
default: false,
group: 'Network Subgraph',
})
.option('index-node-ids', {
description:
'Node IDs of Graph nodes to use for indexing (separated by commas)',
Expand Down Expand Up @@ -729,6 +735,7 @@ export default {
indexer,
network,
networkSubgraph,
allocateOnNetworkSubgraph: argv.allocateOnNetworkSubgraph,
registerIndexer: argv.register,
offchainSubgraphs: argv.offchainSubgraphs.map(
(s: string) => new SubgraphDeploymentID(s),
Expand Down
1 change: 1 addition & 0 deletions packages/indexer-agent/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface AgentConfig {
indexer: Indexer
network: Network
networkSubgraph: NetworkSubgraph
allocateOnNetworkSubgraph: boolean
registerIndexer: boolean
offchainSubgraphs: SubgraphDeploymentID[]
receiptCollector: ReceiptCollector
Expand Down