Skip to content
Closed
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
25 changes: 16 additions & 9 deletions packages/indexer-agent/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,26 +417,33 @@ export class Agent {
},
)

// let targetDeployments be an union of targetAllocations
// and offchain subgraphs.
// Compute target deployments directly from rules.
// This is decoupled from allocation decisions to support deployment management
// even when allocation management is in manual mode.
const targetDeployments: Eventual<SubgraphDeploymentID[]> = join({
indexingRules,
networkDeploymentAllocationDecisions,
}).tryMap(
async ({ indexingRules, networkDeploymentAllocationDecisions }) => {
logger.trace('Resolving target deployments')
const targetDeploymentIDs: Set<SubgraphDeploymentID> =
consolidateAllocationDecisions(networkDeploymentAllocationDecisions)
async ({ indexingRules }) => {
logger.trace('Resolving target deployments from indexing rules')
const targetDeploymentIDs: Set<SubgraphDeploymentID> = new Set()

// Add offchain subgraphs to the deployment list from rules
// Add deployments from rules with decisionBasis ALWAYS or OFFCHAIN
// These are the deployments that should be indexed regardless of allocation mode
Object.values(indexingRules)
.flat()
.filter(
rule => rule?.decisionBasis === IndexingDecisionBasis.OFFCHAIN,
rule =>
rule?.decisionBasis === IndexingDecisionBasis.ALWAYS ||
rule?.decisionBasis === IndexingDecisionBasis.OFFCHAIN,
)
.filter(
rule =>
rule?.identifierType === SubgraphIdentifierType.DEPLOYMENT,
)
.forEach(rule => {
targetDeploymentIDs.add(new SubgraphDeploymentID(rule.identifier))
})

// From startup args
this.offchainSubgraphs.forEach(deployment => {
targetDeploymentIDs.add(deployment)
Expand Down
Loading