solana_accounts_db/
epoch_accounts_hash.rs

1//! The Epoch Accounts Hash (EAH) is a special hash of the whole accounts state that occurs once
2//! per epoch.
3//!
4//! This hash is special because all nodes in the cluster will calculate the accounts hash at a
5//! predetermined slot in the epoch and then save that result into a later Bank at a predetermined
6//! slot.
7//!
8//! This results in all nodes effectively voting on the accounts state (at least) once per epoch.
9
10use {crate::accounts_hash::AccountsHash, solana_hash::Hash};
11
12mod manager;
13pub use manager::Manager as EpochAccountsHashManager;
14
15/// The EpochAccountsHash holds the result after calculating the accounts hash once per epoch
16#[cfg_attr(feature = "frozen-abi", derive(AbiExample))]
17#[derive(Debug, Serialize, Deserialize, Hash, PartialEq, Eq, Clone, Copy)]
18pub struct EpochAccountsHash(Hash);
19
20impl AsRef<Hash> for EpochAccountsHash {
21    fn as_ref(&self) -> &Hash {
22        &self.0
23    }
24}
25
26impl EpochAccountsHash {
27    /// Make an EpochAccountsHash from a regular accounts hash
28    #[must_use]
29    pub const fn new(accounts_hash: Hash) -> Self {
30        Self(accounts_hash)
31    }
32}
33
34impl From<AccountsHash> for EpochAccountsHash {
35    fn from(accounts_hash: AccountsHash) -> EpochAccountsHash {
36        Self::new(accounts_hash.0)
37    }
38}