solana_runtime/snapshot_hash.rs
1//! Helper types and functions for handling and dealing with snapshot hashes.
2use solana_sdk::{clock::Slot, hash::Hash};
3
4/// At startup, when loading from snapshots, the starting snapshot hashes need to be passed to
5/// SnapshotPackagerService, which is in charge of pushing the hashes to CRDS. This struct wraps
6/// up those values make it easier to pass from bank_forks_utils, through validator, to
7/// SnapshotPackagerService.
8#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
9pub struct StartingSnapshotHashes {
10 pub full: FullSnapshotHash,
11 pub incremental: Option<IncrementalSnapshotHash>,
12}
13
14/// Used by SnapshotPackagerService and SnapshotGossipManager, this struct adds type safety to
15/// ensure a full snapshot hash is pushed to the right CRDS.
16#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
17pub struct FullSnapshotHash {
18 pub hash: (Slot, Hash),
19}
20
21/// Used by SnapshotPackagerService and SnapshotGossipManager, this struct adds type safety to
22/// ensure an incremental snapshot hash is pushed to the right CRDS. `base` is the (full) snapshot
23/// this incremental snapshot (`hash`) is based on.
24#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
25pub struct IncrementalSnapshotHash {
26 pub base: (Slot, Hash),
27 pub hash: (Slot, Hash),
28}
29
30/// FullSnapshotHashes is used by SnapshotPackagerService to collect the snapshot hashes from full
31/// snapshots and then push those hashes to CRDS.
32#[derive(Debug, Default, Clone, PartialEq, Eq)]
33pub struct FullSnapshotHashes {
34 pub hashes: Vec<(Slot, Hash)>,
35}
36
37/// IncrementalSnapshotHashes is used by SnapshotPackagerService to collect the snapshot hashes
38/// from incremental snapshots and then push those hashes to CRDS. `base` is the (full) snapshot
39/// all the incremental snapshots (`hashes`) are based on.
40#[derive(Debug, Default, Clone, PartialEq, Eq)]
41pub struct IncrementalSnapshotHashes {
42 pub base: (Slot, Hash),
43 pub hashes: Vec<(Slot, Hash)>,
44}