Skip to content

Commit

Permalink
agent: re-fetch allocations for accurate reconciliation
Browse files Browse the repository at this point in the history
  • Loading branch information
tilacog committed Mar 10, 2023
1 parent d2b87c6 commit d2decbd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/indexer-agent/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,6 @@ class Agent {
}
async reconcileDeploymentAllocationAction(
deploymentAllocationDecision: AllocationDecision,
activeAllocations: Allocation[],
epoch: number,
maxAllocationEpochs: number,
): Promise<void> {
Expand All @@ -764,6 +763,11 @@ class Agent {
epoch,
})

// Acuracy check: re-fetch allocations to ensure that we have a fresh state since the start of the reconciliation loop
const activeAllocations = await this.networkMonitor.allocations(
AllocationStatus.ACTIVE,
)

const activeDeploymentAllocations = activeAllocations.filter(
allocation =>
allocation.subgraphDeployment.id.bytes32 ===
Expand Down Expand Up @@ -866,7 +870,6 @@ class Agent {
await pMap(networkDeploymentAllocationDecisions, async decision => {
await this.reconcileDeploymentAllocationAction(
decision,
activeAllocations,
epoch,
maxAllocationEpochs,
)
Expand Down

0 comments on commit d2decbd

Please sign in to comment.