From 86ba386c815f26d44e5cea47821b7cc72c726772 Mon Sep 17 00:00:00 2001 From: kashepavadan Date: Tue, 26 May 2026 00:22:44 -0400 Subject: [PATCH] remove state for tutorial --- common/src/state.rs | 74 ++------------------------------------------- 1 file changed, 2 insertions(+), 72 deletions(-) diff --git a/common/src/state.rs b/common/src/state.rs index 0489570..ba540b8 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -1,5 +1,5 @@ use lb_core::mantle::ops::channel::MsgId; -use lb_zone_sdk::{sequencer::SequencerCheckpoint, state::InscriptionInfo}; +use lb_zone_sdk::state::InscriptionInfo; use crate::message::Msg; @@ -31,76 +31,6 @@ pub trait ZoneState: Send { fn published(&self) -> &[Msg]; fn adopted(&self) -> &[Msg]; fn finalized(&self) -> &[Msg]; - - fn save_checkpoint(&mut self, checkpoint: SequencerCheckpoint); - fn load_checkpoint(&self) -> Option<&SequencerCheckpoint>; } -/// In-memory implementation of [`ZoneState`]. -#[derive(Default)] -pub struct InMemoryZoneState { - published: Vec, - adopted: Vec, - finalized: Vec, - checkpoint: Option, -} - -impl ZoneState for InMemoryZoneState { - fn on_published(&mut self, info: &InscriptionInfo) { - self.published - .push(Msg::from_payload(info.this_msg, &info.payload)); - } - - fn on_adopted(&mut self, adopted: &[InscriptionInfo]) { - for info in adopted { - if !self.adopted.iter().any(|m| m.msg_id == info.this_msg) { - self.adopted - .push(Msg::from_payload(info.this_msg, &info.payload)); - } - } - } - - fn on_orphaned(&mut self, msg_id: &MsgId) { - if let Some(i) = self.published.iter().position(|m| &m.msg_id == msg_id) { - self.published.remove(i); - } - } - - fn on_finalized(&mut self, inscriptions: &[InscriptionInfo]) { - for info in inscriptions { - if let Some(i) = self - .published - .iter() - .position(|m| m.msg_id == info.this_msg) - { - self.published.remove(i); - } else if let Some(i) = self.adopted.iter().position(|m| m.msg_id == info.this_msg) { - self.adopted.remove(i); - } - if !self.finalized.iter().any(|m| m.msg_id == info.this_msg) { - self.finalized - .push(Msg::from_payload(info.this_msg, &info.payload)); - } - } - } - - fn published(&self) -> &[Msg] { - &self.published - } - - fn adopted(&self) -> &[Msg] { - &self.adopted - } - - fn finalized(&self) -> &[Msg] { - &self.finalized - } - - fn save_checkpoint(&mut self, checkpoint: SequencerCheckpoint) { - self.checkpoint = Some(checkpoint); - } - - fn load_checkpoint(&self) -> Option<&SequencerCheckpoint> { - self.checkpoint.as_ref() - } -} +// Your code here \ No newline at end of file