2022-09-01 09:11:07 -07:00
|
|
|
//! The Epoch Accounts Hash (EAH) is a special hash of the whole accounts state that occurs once
|
|
|
|
//! per epoch.
|
|
|
|
//!
|
|
|
|
//! This hash is special because all nodes in the cluster will calculate the accounts hash at a
|
|
|
|
//! predetermined slot in the epoch and then save that result into a later Bank at a predetermined
|
|
|
|
//! slot.
|
|
|
|
//!
|
|
|
|
//! This results in all nodes effectively voting on the accounts state (at least) once per epoch.
|
|
|
|
|
2022-11-28 07:09:47 -08:00
|
|
|
use {crate::accounts_hash::AccountsHash, solana_sdk::hash::Hash};
|
2022-10-05 16:29:22 -07:00
|
|
|
|
2022-10-05 14:44:35 -07:00
|
|
|
mod manager;
|
|
|
|
pub use manager::Manager as EpochAccountsHashManager;
|
|
|
|
|
2022-09-01 09:11:07 -07:00
|
|
|
/// The EpochAccountsHash holds the result after calculating the accounts hash once per epoch
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Hash, PartialEq, Eq, Clone, Copy)]
|
|
|
|
pub struct EpochAccountsHash(Hash);
|
|
|
|
|
|
|
|
impl AsRef<Hash> for EpochAccountsHash {
|
|
|
|
fn as_ref(&self) -> &Hash {
|
|
|
|
&self.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-07 10:07:00 -07:00
|
|
|
impl EpochAccountsHash {
|
|
|
|
/// Make an EpochAccountsHash from a regular accounts hash
|
|
|
|
#[must_use]
|
2022-10-05 14:44:35 -07:00
|
|
|
pub const fn new(accounts_hash: Hash) -> Self {
|
2022-09-07 10:07:00 -07:00
|
|
|
Self(accounts_hash)
|
|
|
|
}
|
|
|
|
}
|
2022-11-28 07:09:47 -08:00
|
|
|
|
|
|
|
impl From<AccountsHash> for EpochAccountsHash {
|
|
|
|
fn from(accounts_hash: AccountsHash) -> EpochAccountsHash {
|
|
|
|
Self::new(accounts_hash.0)
|
|
|
|
}
|
|
|
|
}
|