Skip to content

Commit d550de9

Browse files
committed
Add option to allocate on network subgraph
1 parent 571ed31 commit d550de9

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

packages/indexer-agent/src/agent.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class Agent {
5959
indexer: Indexer
6060
network: Network
6161
networkSubgraph: NetworkSubgraph
62+
allocateOnNetworkSubgraph: boolean
6263
registerIndexer: boolean
6364
offchainSubgraphs: SubgraphDeploymentID[]
6465
receiptCollector: ReceiptCollector
@@ -69,6 +70,7 @@ class Agent {
6970
indexer: Indexer,
7071
network: Network,
7172
networkSubgraph: NetworkSubgraph,
73+
allocateOnNetworkSubgraph: boolean,
7274
registerIndexer: boolean,
7375
offchainSubgraphs: SubgraphDeploymentID[],
7476
receiptCollector: ReceiptCollector,
@@ -78,6 +80,7 @@ class Agent {
7880
this.indexer = indexer
7981
this.network = network
8082
this.networkSubgraph = networkSubgraph
83+
this.allocateOnNetworkSubgraph = allocateOnNetworkSubgraph
8184
this.registerIndexer = registerIndexer
8285
this.offchainSubgraphs = offchainSubgraphs
8386
this.receiptCollector = receiptCollector
@@ -580,8 +583,11 @@ class Agent {
580583
...activeAllocations.map(allocation => allocation.subgraphDeployment.id),
581584
])
582585

583-
// Ensure the network subgraph is never allocated towards
584-
if (this.networkSubgraph.deployment?.id.bytes32) {
586+
// Ensure the network subgraph is never allocated towards unless explicitly allowed
587+
if (
588+
!this.allocateOnNetworkSubgraph &&
589+
this.networkSubgraph.deployment?.id.bytes32
590+
) {
585591
const networkSubgraphDeploymentId = this.networkSubgraph.deployment.id
586592
targetDeployments = targetDeployments.filter(
587593
deployment =>
@@ -919,6 +925,7 @@ export const startAgent = async (config: AgentConfig): Promise<Agent> => {
919925
config.indexer,
920926
config.network,
921927
config.networkSubgraph,
928+
config.allocateOnNetworkSubgraph,
922929
config.registerIndexer,
923930
config.offchainSubgraphs,
924931
config.receiptCollector,

packages/indexer-agent/src/commands/start.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ export default {
154154
type: 'string',
155155
group: 'Network Subgraph',
156156
})
157+
.option('allocate-on-network-subgraph', {
158+
description: 'Whether to allocate to the network subgraph',
159+
type: 'boolean',
160+
default: false,
161+
group: 'Network Subgraph',
162+
})
157163
.option('index-node-ids', {
158164
description:
159165
'Node IDs of Graph nodes to use for indexing (separated by commas)',
@@ -729,6 +735,7 @@ export default {
729735
indexer,
730736
network,
731737
networkSubgraph,
738+
allocateOnNetworkSubgraph: argv.allocateOnNetworkSubgraph,
732739
registerIndexer: argv.register,
733740
offchainSubgraphs: argv.offchainSubgraphs.map(
734741
(s: string) => new SubgraphDeploymentID(s),

packages/indexer-agent/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface AgentConfig {
1010
indexer: Indexer
1111
network: Network
1212
networkSubgraph: NetworkSubgraph
13+
allocateOnNetworkSubgraph: boolean
1314
registerIndexer: boolean
1415
offchainSubgraphs: SubgraphDeploymentID[]
1516
receiptCollector: ReceiptCollector

0 commit comments

Comments
 (0)