Skip to content

Commit

Permalink
error handling in sync
Browse files Browse the repository at this point in the history
  • Loading branch information
zavelevsky committed Dec 14, 2024
1 parent b14cb50 commit 6364067
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/chain-cache/ChainSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,24 @@ export class ChainSync {
) {
batches.push(this._uncachedPairs.slice(i, i + this._numOfPairsToBatch));
}
this._uncachedPairs = [];
const strategiesBatches = await Promise.all(
batches.map((batch) => this._fetcher.strategiesByPairs(batch))
);
strategiesBatches.flat().forEach((pairStrategies) => {
this._chainCache.addPair(
pairStrategies.pair[0],
pairStrategies.pair[1],
pairStrategies.strategies,
true

try {
const strategiesBatches = await Promise.all(
batches.map((batch) => this._fetcher.strategiesByPairs(batch))
);
});
strategiesBatches.flat().forEach((pairStrategies) => {
this._chainCache.addPair(
pairStrategies.pair[0],
pairStrategies.pair[1],
pairStrategies.strategies,
true
);
});
this._uncachedPairs = [];
} catch (error) {
logger.error('Failed to fetch strategies for pairs batch:', error);
throw error; // Re-throw to be handled by caller
}
}

public async syncPairData(token0: string, token1: string): Promise<void> {
Expand Down

0 comments on commit 6364067

Please sign in to comment.