#[derive(Clone, Copy, Debug)]
pub(crate) struct SimEvent {
pub(crate) seq: u64,
pub(crate) hash: u64,
pub(crate) durable: bool,
}
#[derive(Default)]
pub(crate) struct ModelState {
pub(crate) log: Vec<SimEvent>,
pub(crate) visible_frontier: u64,
}
impl ModelState {
pub(crate) fn append(&mut self, event: SimEvent) {
if event.durable {
self.visible_frontier = self.visible_frontier.max(event.seq);
}
self.log.push(event);
}
pub(crate) fn chain_head(&self) -> u64 {
self.log
.iter()
.rev()
.find(|e| e.durable)
.map_or(0, |e| e.hash)
}
}