Skip to content

Commit 05d1a24

Browse files
committed
revert unneeded changes to more clarity of PR
1 parent 3dd431b commit 05d1a24

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

packages/framework/src/services/indexer/src/entityFetcher.ts

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ export interface TransactionResponse<T> {
5454
export abstract class BaseIndexerEntityFetcher<
5555
T extends ParsedEntity<unknown>,
5656
> {
57-
protected retryPendingSignaturesJob!: Utils.JobRunner
57+
protected checkPendingRetriesJob!: Utils.JobRunner
5858
protected checkCompletionJob!: Utils.DebouncedJob<void>
5959
protected requestFutures: Record<number, Utils.Future<number>> = {}
6060
protected requestMutex = new Mutex()
6161
protected events: EventEmitter = new EventEmitter()
6262
protected incomingEntities: PendingWorkPool<T>
63-
protected pendingRequestToRetryBuffer: Utils.BufferExec<EntityRequestPendingEntity>
64-
protected pendingRequestToRemoveBuffer: Utils.BufferExec<EntityRequestPendingEntity>
63+
protected toRetryBuffer: Utils.BufferExec<EntityRequestPendingEntity>
64+
protected toRemoveBuffer: Utils.BufferExec<EntityRequestPendingEntity>
6565

6666
constructor(
6767
protected type: IndexableEntityType,
@@ -83,35 +83,35 @@ export abstract class BaseIndexerEntityFetcher<
8383
checkComplete: async (): Promise<boolean> => true,
8484
})
8585

86-
this.retryPendingSignaturesJob = new JobRunner({
87-
name: `${type}-indexer-retry-pending-signatures`,
86+
this.checkPendingRetriesJob = new JobRunner({
87+
name: `${type}-indexer-pending-retries`,
8888
interval: 1000 * 60 * 10,
89-
intervalFn: this.retryPendingSignatures.bind(this),
89+
intervalFn: this.handlePendingRetries.bind(this),
9090
})
9191

9292
this.checkCompletionJob = new DebouncedJob<void>(
9393
this.checkAllRequestCompletion.bind(this),
9494
)
9595

96-
this.pendingRequestToRetryBuffer = new BufferExec<EntityRequestPendingEntity>(
96+
this.toRetryBuffer = new BufferExec<EntityRequestPendingEntity>(
9797
this.handleRetryPendingEntities.bind(this),
9898
1000,
9999
)
100100

101-
this.pendingRequestToRemoveBuffer = new BufferExec<EntityRequestPendingEntity>(
101+
this.toRemoveBuffer = new BufferExec<EntityRequestPendingEntity>(
102102
this.handleRemovePendingTransactions.bind(this),
103103
1000,
104104
)
105105
}
106106

107107
async start(): Promise<void> {
108108
await this.incomingEntities.start()
109-
this.retryPendingSignaturesJob.start().catch(() => 'ignore')
109+
this.checkPendingRetriesJob.start().catch(() => 'ignore')
110110
}
111111

112112
async stop(): Promise<void> {
113113
await this.incomingEntities.stop()
114-
this.retryPendingSignaturesJob.stop().catch(() => 'ignore')
114+
this.checkPendingRetriesJob.stop().catch(() => 'ignore')
115115
}
116116

117117
async fetchEntitiesById(params: IdRange): Promise<number> {
@@ -486,7 +486,17 @@ export abstract class BaseIndexerEntityFetcher<
486486
this.resolveFuture(nonce)
487487
}
488488

489-
protected async checkPendingSignature(
489+
protected async checkAllPendingSignatures(): Promise<void> {
490+
const requests = await this.entityRequestDAL.getAllValues()
491+
492+
for await (const request of requests) {
493+
await this.checkPendingSignatures(request, false)
494+
}
495+
496+
await this.drainPendingSignaturesBuffer()
497+
}
498+
499+
protected async checkPendingSignatures(
490500
request: EntityRequest,
491501
drain = true,
492502
): Promise<void> {
@@ -512,8 +522,8 @@ export abstract class BaseIndexerEntityFetcher<
512522
const hasResponse = !!tx && 'parsed' in tx && tx.nonceIndexes[nonce] >= 0
513523

514524
hasResponse
515-
? await this.pendingRequestToRemoveBuffer.add(pending)
516-
: await this.pendingRequestToRetryBuffer.add(pending)
525+
? await this.toRemoveBuffer.add(pending)
526+
: await this.toRetryBuffer.add(pending)
517527
}
518528

519529
if (drain) {
@@ -522,16 +532,12 @@ export abstract class BaseIndexerEntityFetcher<
522532
}
523533

524534
protected async drainPendingSignaturesBuffer(): Promise<void> {
525-
await this.pendingRequestToRemoveBuffer.drain()
526-
await this.pendingRequestToRetryBuffer.drain()
535+
await this.toRemoveBuffer.drain()
536+
await this.toRetryBuffer.drain()
527537
}
528538

529-
protected async retryPendingSignatures(): Promise<void> {
530-
const requests = await this.entityRequestDAL.getAllValues()
531-
for await (const request of requests) {
532-
await this.checkPendingSignature(request, false)
533-
}
534-
await this.drainPendingSignaturesBuffer()
539+
protected async handlePendingRetries(): Promise<void> {
540+
await this.checkAllPendingSignatures()
535541
await this.checkCompletionJob.run()
536542
}
537543

0 commit comments

Comments
 (0)