Skip to content

Commit

Permalink
fix(history-importer-task) move check for recent log error to correct…
Browse files Browse the repository at this point in the history
… place
  • Loading branch information
tmrdlt committed Oct 16, 2024
1 parent 6492e40 commit c1deed7
Showing 1 changed file with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,22 @@ export class PairLiquidityInfoHistoryImporterService {
let numUpserted = 0;
for (const current of logsAndEvents) {
try {
// If an error occurred for this log recently, skip block
const error =
await this.pairLiquidityInfoHistoryErrorDb.getErrorWithinHours(
pairWithTokens.id,
current.log.block_hash,
current.log.call_tx_hash,
parseInt(current.log.log_idx),
this.WITHIN_HOURS_TO_SKIP_IF_ERROR,
);
if (error) {
this.logger.log(
`Skipped log with block hash ${current.log.block_hash} tx hash ${current.log.call_tx_hash} and log index ${current.log.log_idx} due to recent error.`,
);
continue;
}

const succeeding =
logsAndEvents[logsAndEvents.indexOf(current) + 1];

Expand Down Expand Up @@ -233,22 +249,6 @@ export class PairLiquidityInfoHistoryImporterService {
continue;
}

// If an error occurred for this log recently, skip block
const error =
await this.pairLiquidityInfoHistoryErrorDb.getErrorWithinHours(
pairWithTokens.id,
current.log.block_hash,
current.log.call_tx_hash,
parseInt(current.log.log_idx),
this.WITHIN_HOURS_TO_SKIP_IF_ERROR,
);
if (error) {
this.logger.log(
`Skipped log with block hash ${current.log.block_hash} tx hash ${current.log.call_tx_hash} and log index ${current.log.log_idx} due to recent error.`,
);
continue;
}

// Upsert liquidity
await this.pairLiquidityInfoHistoryDb
.upsert(liquidityInfo)
Expand Down

0 comments on commit c1deed7

Please sign in to comment.