Skip to content

Commit

Permalink
Fix backfilling not contigous blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Ktl-XV committed Jan 24, 2024
1 parent 1f8aa6d commit b0bfd14
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/scripts/pull_and_save_block_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,25 +139,25 @@ function parseTransactionEvents(transaction: FullTransaction): ParsedTransaction
};
}

type range = {
type BlockRange = {
start: number;
end: number;
};

function findRanges(nums: number[]): range[] {
const sorted = [...new Set(nums)].sort();
const ranges: { start: number; end: number }[] = [];
function findRanges(nums: number[]): BlockRange[] {
const sorted = [...new Set(nums)].sort((a, b) => a - b);
const ranges: BlockRange[] = [];
const currentRange = { start: sorted[0], end: sorted[0] };
for (let i = 1; i < sorted.length; i++) {
if (currentRange.end + 1 === sorted[i]) {
currentRange.end = sorted[i];
} else {
ranges.push(currentRange);
ranges.push(structuredClone(currentRange));
currentRange.start = sorted[i];
currentRange.end = sorted[i];
}
}
ranges.push(currentRange);
ranges.push(structuredClone(currentRange));
return ranges;
}

Expand Down
2 changes: 1 addition & 1 deletion src/tokenMetadataSingleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class TokenMetadataSingleton {
static async getInstance(connection: Connection, producer: Producer | null): Promise<TokenMetadataSingleton> {
if (!TokenMetadataSingleton.instance) {
TokenMetadataSingleton.instance = new TokenMetadataSingleton();
logger.info(`Loading the top ${MAX_INITIAL_TOKENS} to memory`);
logger.info(`Loading the top ${MAX_INITIAL_TOKENS} tokens to memory`);
const tmp = await connection
.getRepository(TokenMetadata)
.createQueryBuilder('token_metadata')
Expand Down

0 comments on commit b0bfd14

Please sign in to comment.