Skip to content

Commit

Permalink
fix: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
0xnigir1 committed Nov 1, 2024
1 parent d88a2d3 commit d594c3e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/data-flow/src/orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ import {
stringify,
} from "@grants-stack-indexer/shared";

import type { IEventsFetcher, IEventsRegistry, IStrategyRegistry } from "./interfaces/index.js";
import { EventsFetcher } from "./eventsFetcher.js";
import { EventsProcessor } from "./eventsProcessor.js";
import { InvalidEvent } from "./exceptions/index.js";
import { IEventsRegistry } from "./interfaces/eventsRegistry.interface.js";
import { IEventsFetcher } from "./interfaces/index.js";
import { IStrategyRegistry } from "./interfaces/strategyRegistry.interface.js";
import { CoreDependencies, DataLoader, delay, IQueue, iStrategyAbi, Queue } from "./internal.js";

/**
Expand Down Expand Up @@ -94,7 +92,7 @@ export class Orchestrator {
while (!signal.aborted) {
let event: ProcessorEvent<ContractName, AnyEvent> | undefined;
try {
if (this.eventsQueue.isEmpty()) await this.fillQueue();
if (this.eventsQueue.isEmpty()) await this.enqueueEvents();

event = this.eventsQueue.pop();

Expand Down Expand Up @@ -147,9 +145,9 @@ export class Orchestrator {
}

/**
* Fill the events queue with the events from the events fetcher
* Enqueue new events from the events fetcher using the last processed event as a starting point
*/
private async fillQueue(): Promise<void> {
private async enqueueEvents(): Promise<void> {
const lastProcessedEvent = await this.eventsRegistry.getLastProcessedEvent();
const blockNumber = lastProcessedEvent?.blockNumber ?? 0;
const logIndex = lastProcessedEvent?.logIndex ?? 0;
Expand Down
7 changes: 7 additions & 0 deletions packages/data-flow/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ export type ExecutionResult = {
errors: string[];
};

/**
* The core dependencies for the data flow
*
* Note: for Repositories, we type the Read & Write interfaces
* while the ProcessorDependencies type uses the ReadOnly interfaces
* so that's why we need this type
*/
export type CoreDependencies = Pick<
ProcessorDependencies,
"evmProvider" | "pricingProvider" | "metadataProvider"
Expand Down

0 comments on commit d594c3e

Please sign in to comment.