Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/skip pre nakamoto reward set lookup #21

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/pg/chainhook/chainhook-pg-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,11 @@ export class ChainhookPgStore extends BasePgStoreModule {
}

private async insertBlock(sql: PgSqlClient, dbBlock: DbBlock) {
const skipRewardSetCheck = this.isMainnet && dbBlock.burn_block_height < 867867;
if (skipRewardSetCheck) {
await sql`
INSERT INTO blocks ${sql(dbBlock)}
`;
return;
// Skip pre-nakamoto blocks
if (!dbBlock.is_nakamoto_block) {
logger.info(
`ChainhookPgStore skipping apply for pre-nakamoto block ${dbBlock.block_height} ${dbBlock.block_hash}`
);
} else {
// After the block is inserted, calculate the reward_cycle_number, then check if the reward_set_signers
// table contains any rows for the calculated cycle_number.
Expand Down Expand Up @@ -467,8 +466,8 @@ export class ChainhookPgStore extends BasePgStoreModule {
// Use setImmediate to ensure we break out of the current sql transaction within the async context
setImmediate(() => this.events.emit('missingStackerSet', { cycleNumber: cycle_number }));
}
logger.info(`ChainhookPgStore apply block ${dbBlock.block_height} ${dbBlock.block_hash}`);
}
logger.info(`ChainhookPgStore apply block ${dbBlock.block_height} ${dbBlock.block_hash}`);
}

private async insertBlockSignerSignatures(
Expand Down
Loading