Skip to content

Commit

Permalink
Decrease default block range for distribution events
Browse files Browse the repository at this point in the history
  • Loading branch information
vanruch committed Jun 25, 2024
1 parent 1e228ee commit 18c720b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/rewards-calculator/src/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function getRegistrations() {
export type Registrations = Awaited<ReturnType<typeof getRegistrations>>;

export async function getLatestDistributionBlock() {
const toBlock = (await publicClient.getBlockNumber()) - 1000n;
const toBlock = await publicClient.getBlockNumber();
let offset = 1000n;
while (offset <= toBlock) {
const distributionBlocks = (
Expand All @@ -42,7 +42,8 @@ export async function getLatestDistributionBlock() {
fromBlock: toBlock - offset,
})
).map(({ blockNumber }) => Number(blockNumber));
if (distributionBlocks.length >= 0) {
console.log(distributionBlocks);
if (distributionBlocks.length > 0) {
const maxBlock = Math.max(...distributionBlocks);
return BigInt(maxBlock);
}
Expand Down

2 comments on commit 18c720b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.