Skip to content
Open
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: 10 additions & 3 deletions graph/src/components/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,9 +1059,16 @@ impl PruneRequest {
));
}

// We need to add + 1 to `earliset_block` because the lower bound is inclusive
// and otherwise we would end up with `history_blocks + 1` blocks of history instead of `history_blocks`
let earliest_block = latest_block - history_blocks + 1;
// Note: this intentionally keeps `history_blocks + 1` blocks on disk.
// The range [earliest_block, latest_block] is inclusive on both ends,
// so it contains `history_blocks + 1` entries. The extra block is a
// required buffer: `revert_block_ptr` requires at least
// `reorg_threshold + 2` actual blocks on disk to allow even a
// single-block reorg after pruning, and `strategy` requires
// `earliest_block < final_block`. Both conditions are satisfied when
// `history_blocks >= reorg_threshold + 1`, which gives
// `reorg_threshold + 2` blocks on disk.
let earliest_block = latest_block - history_blocks;
let final_block = latest_block - reorg_threshold;

Ok(Self {
Expand Down