Add fn to check when to take snapshots (#19682)

This commit is contained in:
Brooks Prumo
2021-09-07 18:26:35 -05:00
committed by GitHub
parent 85571c93a4
commit 4a5f83d3a7
4 changed files with 37 additions and 16 deletions

View File

@@ -1795,6 +1795,22 @@ pub fn package_and_archive_incremental_snapshot(
))
}
pub fn should_take_full_snapshot(
block_height: Slot,
full_snapshot_archive_interval_slots: Slot,
) -> bool {
block_height % full_snapshot_archive_interval_slots == 0
}
pub fn should_take_incremental_snapshot(
block_height: Slot,
incremental_snapshot_archive_interval_slots: Slot,
last_full_snapshot_slot: Option<Slot>,
) -> bool {
block_height % incremental_snapshot_archive_interval_slots == 0
&& last_full_snapshot_slot.is_some()
}
#[cfg(test)]
mod tests {
use super::*;