Skip to content

Commit

Permalink
fix: clear blocks on reset
Browse files Browse the repository at this point in the history
When we reset we will visit old blocks again so we need to clear
previously stored ones to avoid conflicts.
  • Loading branch information
Sekhmet committed Nov 7, 2024
1 parent fccbfcd commit fd8d7db
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@snapshot-labs/checkpoint",
"version": "0.1.0-beta.42",
"version": "0.1.0-beta.43",
"license": "MIT",
"bin": {
"checkpoint": "dist/src/bin/index.js"
Expand Down
1 change: 1 addition & 0 deletions src/checkpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export default class Checkpoint {
await this.store.createStore();
await this.store.setMetadata(MetadataId.LastIndexedBlock, 0);
await this.store.setMetadata(MetadataId.SchemaVersion, SCHEMA_VERSION);
await this.store.removeBlocks();

await this.entityController.createEntityStores(this.knex);
}
Expand Down
4 changes: 4 additions & 0 deletions src/stores/checkpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ export class CheckpointsStore {
await this.createStore();
}

public async removeBlocks(): Promise<void> {
return this.knex(Table.Blocks).del();
}

public async getBlockHash(blockNumber: number): Promise<string | null> {
const blocks = await this.knex
.select(Fields.Blocks.Hash)
Expand Down

0 comments on commit fd8d7db

Please sign in to comment.