Skip to content

Commit

Permalink
allow rescan multiple blocks in single notification
Browse files Browse the repository at this point in the history
  • Loading branch information
ashkuc committed Jul 25, 2023
1 parent 14073ef commit 1680416
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
18 changes: 15 additions & 3 deletions apps/crawler/src/subscribers/subscribers.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,22 @@ export class SubscribersService {
this.logger.log(`Received notification on channel ${channel}`);

if (channel === FORCE_RESCAN_BLOCK && payload) {
const blockNumber = parseInt(payload, 10);
const blockNumbers = payload
.split(',')
.map((n) => parseInt(n.trim(), 10))
.filter((n) => !isNaN(n));

this.logger.log(`Force rescan called for block ${blockNumber} started`);
await this.blocksSubscriberService.processBlockByNumber(blockNumber);
this.logger.log(
`Going to force rescan blocks: ${blockNumbers.join(', ')}`,
);

for (const blockNumber of blockNumbers) {
this.logger.log(`Rescan for block ${blockNumber}`);

await this.blocksSubscriberService.processBlockByNumber(blockNumber);

this.logger.log(`Rescan for block ${blockNumber} finished`);
}
}
});

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polkastats-backend-uniquenetwork",
"version": "2.0.55",
"version": "2.0.56",
"description": "",
"author": "Unique Network Team",
"private": true,
Expand Down

0 comments on commit 1680416

Please sign in to comment.