Skip to content

Commit

Permalink
docs: explain checkpoint file
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI committed Feb 8, 2024
1 parent 03482bf commit ec763a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Extract logs expected by [firehose-starknet](https://github.com/starknet-graph/f

This tool exists because it could be slow to sync a Starknet node from scratch, which is currently the only way to bootstrap a [firehose-starknet](https://github.com/starknet-graph/firehose-starknet) deployment. This tool makes calls to the JSON-RPC endpoint offered by a trusted synced node, and emits the exact same format as an instrumented client node would do.

## Checkpoint file

This tool keeps track of the sync progress through a _checkpoint_ file, specified by the `--checkpoint` command line option or `CHECKPOINT_FILE` environment variable. The content of the checkpoint file is updated every `50` blocks, which means it's likely that some blocks might be sycned more than once when the tool restarts. This is fine as Firehose handles duplicated blocks without issue.

## License

Licensed under either of
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ async fn run(
};

if checkpoint.latest_blocks.len() >= MAX_BLOCK_HISTORY {
// TODO: use ring buffer instead as this is extremely inefficient
checkpoint.latest_blocks.remove(0);
}
checkpoint.latest_blocks.push(new_block_info);
Expand Down

0 comments on commit ec763a2

Please sign in to comment.