atlas_runtime/
snapshot_hash.rs

1//! Helper types and functions for handling and dealing with snapshot hashes.
2use {
3    solana_clock::Slot, solana_hash::Hash,
4    solana_lattice_hash::lt_hash::Checksum as AccountsLtHashChecksum,
5};
6
7/// At startup, when loading from snapshots, the starting snapshot hashes need to be passed to
8/// SnapshotPackagerService, which is in charge of pushing the hashes to CRDS.  This struct wraps
9/// up those values make it easier to pass from bank_forks_utils, through validator, to
10/// SnapshotPackagerService.
11#[derive(Debug, Clone, Copy, PartialEq, Eq)]
12pub struct StartingSnapshotHashes {
13    pub full: FullSnapshotHash,
14    pub incremental: Option<IncrementalSnapshotHash>,
15}
16
17/// Used by SnapshotPackagerService and SnapshotGossipManager, this struct adds type safety to
18/// ensure a full snapshot hash is pushed to the right CRDS.
19#[derive(Debug, Clone, Copy, PartialEq, Eq)]
20pub struct FullSnapshotHash(pub (Slot, SnapshotHash));
21
22/// Used by SnapshotPackagerService and SnapshotGossipManager, this struct adds type safety to
23/// ensure an incremental snapshot hash is pushed to the right CRDS.
24#[derive(Debug, Clone, Copy, PartialEq, Eq)]
25pub struct IncrementalSnapshotHash(pub (Slot, SnapshotHash));
26
27/// The hash used for snapshot archives
28#[derive(Debug, PartialEq, Eq, Clone, Copy)]
29pub struct SnapshotHash(pub Hash);
30
31impl SnapshotHash {
32    /// Make a snapshot hash from accounts hashes
33    #[must_use]
34    pub fn new(accounts_lt_hash_checksum: AccountsLtHashChecksum) -> Self {
35        let accounts_hash = Hash::new_from_array(accounts_lt_hash_checksum.0);
36        Self(accounts_hash)
37    }
38}