Skip to content

Commit 4b1726f

Browse files
committed
agent, common: address review comments on removal of multinetwork
1 parent afe2544 commit 4b1726f

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

packages/indexer-agent/src/agent.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,13 @@ export class Agent {
184184
}
185185

186186
reconciliationLoop() {
187+
const { network, operator } = this.networkAndOperator
187188
const requestIntervalSmall = this.pollingInterval
188189
const requestIntervalLarge = this.pollingInterval * 5
189190
const logger = this.logger.child({ component: 'ReconciliationLoop' })
190191
const currentEpochNumber: Eventual<number> = sequentialTimerMap(
191192
{ logger, milliseconds: requestIntervalLarge },
192193
async () => {
193-
const { network } = this.networkAndOperator
194194
logger.trace('Fetching current epoch number', {
195195
protocolNetwork: network.specification.networkIdentifier,
196196
})
@@ -202,8 +202,6 @@ export class Agent {
202202
},
203203
)
204204

205-
const { network } = this.networkAndOperator
206-
207205
const maxAllocationEpochs: Eventual<number> = sequentialTimerMap(
208206
{ logger, milliseconds: requestIntervalLarge },
209207
async () => {
@@ -222,7 +220,6 @@ export class Agent {
222220
sequentialTimerMap(
223221
{ logger, milliseconds: requestIntervalSmall },
224222
async () => {
225-
const { network, operator } = this.networkAndOperator
226223
logger.trace('Fetching indexing rules', {
227224
protocolNetwork: network.specification.networkIdentifier,
228225
})
@@ -260,7 +257,6 @@ export class Agent {
260257
sequentialTimerMap(
261258
{ logger, milliseconds: requestIntervalLarge },
262259
async () => {
263-
const { network } = this.networkAndOperator
264260
if (
265261
this.deploymentManagement === DeploymentManagementMode.AUTO ||
266262
network.networkMonitor.poiDisputeMonitoringEnabled()
@@ -290,7 +286,6 @@ export class Agent {
290286
sequentialTimerMap(
291287
{ logger, milliseconds: requestIntervalSmall },
292288
async () => {
293-
const { network } = this.networkAndOperator
294289
logger.trace('Fetching network deployments', {
295290
protocolNetwork: network.specification.networkIdentifier,
296291
})
@@ -367,7 +362,6 @@ export class Agent {
367362
const activeAllocations: Eventual<Allocation[]> = sequentialTimerMap(
368363
{ logger, milliseconds: requestIntervalSmall },
369364
async () => {
370-
const { network } = this.networkAndOperator
371365
logger.trace('Fetching active allocations', {
372366
protocolNetwork: network.specification.networkIdentifier,
373367
})
@@ -389,13 +383,12 @@ export class Agent {
389383
}).tryMap(
390384
// eslint-disable-next-line @typescript-eslint/no-unused-vars
391385
async ({ activeAllocations: _, currentEpochNumber }) => {
392-
const { network } = this.networkAndOperator
393-
const allocationsByNetwork =
386+
const recentlyClosedAllocations =
394387
await network.networkMonitor.recentlyClosedAllocations(
395388
currentEpochNumber,
396389
1,
397390
)
398-
return Object.values(allocationsByNetwork).flat()
391+
return Object.values(recentlyClosedAllocations).flat()
399392
},
400393
{
401394
onError: () =>
@@ -410,7 +403,6 @@ export class Agent {
410403
activeDeployments,
411404
}).tryMap(
412405
async ({ currentEpochNumber, activeDeployments }) => {
413-
const { network } = this.networkAndOperator
414406
logger.trace('Fetching disputable allocations', {
415407
protocolNetwork: network.specification.networkIdentifier,
416408
currentEpochNumber,
@@ -455,7 +447,6 @@ export class Agent {
455447
})
456448

457449
try {
458-
const { network, operator } = this.networkAndOperator
459450
const disputableEpochs =
460451
currentEpochNumber -
461452
network.specification.indexerOptions.poiDisputableEpochs
@@ -918,7 +909,7 @@ export class Agent {
918909
// Network Subgraph is NEVER allocated towards
919910
// --------------------------------------------------------------------------------
920911
const { network, operator } = this.networkAndOperator
921-
let validatedAllocationDecisions = allocationDecisions
912+
let validatedAllocationDecisions = [...allocationDecisions]
922913

923914
if (
924915
network.specification.indexerOptions.allocationManagementMode ===
@@ -940,12 +931,12 @@ export class Agent {
940931
networkSubgraphDeployment &&
941932
!network.specification.indexerOptions.allocateOnNetworkSubgraph
942933
) {
943-
const networkSubgraphIndex = allocationDecisions.findIndex(
934+
const networkSubgraphIndex = validatedAllocationDecisions.findIndex(
944935
decision =>
945936
decision.deployment.bytes32 == networkSubgraphDeployment.id.bytes32,
946937
)
947938
if (networkSubgraphIndex >= 0) {
948-
allocationDecisions[networkSubgraphIndex].toAllocate = false
939+
validatedAllocationDecisions[networkSubgraphIndex].toAllocate = false
949940
}
950941
}
951942
}

packages/indexer-common/src/indexer-management/actions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export class ActionManager {
146146
const networkLogger = logger.child({
147147
protocolNetwork: this.network.specification.networkIdentifier,
148148
indexer: this.network.specification.indexerOptions.address,
149+
operator: this.network.transactionManager.wallet.address,
149150
})
150151

151152
if (await this.batchReady(approvedActions, this.network, networkLogger)) {

packages/indexer-common/src/indexer-management/resolvers/allocations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,14 +354,14 @@ export default {
354354
protocolNetwork: network.specification.networkIdentifier,
355355
}
356356

357-
const allocationsByNetwork = await queryAllocations(
357+
const allocationsResult = await queryAllocations(
358358
logger,
359359
networkSubgraph,
360360
variables,
361361
context,
362362
)
363363

364-
return Object.values(allocationsByNetwork).flat()
364+
return Object.values(allocationsResult).flat()
365365
},
366366

367367
createAllocation: async (

0 commit comments

Comments
 (0)