Skip to content

Commit

Permalink
Merge pull request zkLinkProtocol#123 from zkLinkProtocol/feat-direct…
Browse files Browse the repository at this point in the history
…PointOp

fix direact points.
  • Loading branch information
zkcarter authored Jul 26, 2024
2 parents 48c2e49 + 094574d commit 3ef6c57
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export class AppService implements OnModuleInit, OnModuleDestroy {
// second params is utc+8
// await this.tvlPointService.handleHoldPoint(1395273, new Date(1715159940 * 1000).toISOString());
// this.compensatePoints()
await this.directPointService.runProcess();
this.redistributePointService.runProcess();
this.startWorkers();
}
Expand Down
22 changes: 12 additions & 10 deletions src/points/directPoint.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,20 @@ export class DirectPointService extends Worker {

public async runProcess(): Promise<void> {
const blockNumbers = await this.directHoldProcessingStatusRepository.getUnprocessedBlockNumber();
if (blockNumbers.length === 0) {
this.logger.log(`No block to process`);
return;
}
for (const blockNumber of blockNumbers) {
try {
await this.handleHoldPoint(blockNumber.blockNumber);
} catch (error) {
this.logger.error("Failed to calculate hold point", error.stack);
if (blockNumbers.length > 0) {
for (const blockNumber of blockNumbers) {
try {
await this.handleHoldPoint(blockNumber.blockNumber);
} catch (error) {
this.logger.error("Failed to calculate hold point", error.stack);
}
}
await waitFor(() => !this.currentProcessPromise, 10000, 10000);
if (!this.currentProcessPromise) {
return;
}
}
await waitFor(() => false, 1000, 1000);
return this.runProcess();
}

async handleHoldPoint(currentBlockNumber: number) {
Expand Down

0 comments on commit 3ef6c57

Please sign in to comment.