use crate::{
ballot_leader_election::Ballot,
messages::ballot_leader_election::HeartbeatReply,
storage::Entry,
util::{LeaderState, NodeId},
};
#[derive(Debug, Clone, Default)]
pub struct ClusterState {
pub accepted_indexes: Vec<u64>,
pub heartbeats: Vec<HeartbeatReply>,
}
impl<T> From<&LeaderState<T>> for ClusterState
where
T: Entry,
{
fn from(leader_state: &LeaderState<T>) -> Self {
let mut accepted_indexes = leader_state.accepted_indexes.clone();
accepted_indexes.insert(0, 0);
Self {
accepted_indexes,
heartbeats: vec![],
}
}
}
pub struct OmniPaxosStates {
pub current_ballot: Ballot,
pub current_leader: Option<NodeId>,
pub decided_idx: u64,
pub heartbeats: Vec<HeartbeatReply>,
pub cluster_state: ClusterState,
}