diff --git a/src/list/raxos/protocal/src/apaxos/history.rs b/src/list/raxos/protocal/src/apaxos/history.rs index f8c474a..5957bef 100644 --- a/src/list/raxos/protocal/src/apaxos/history.rs +++ b/src/list/raxos/protocal/src/apaxos/history.rs @@ -55,18 +55,6 @@ where /// All `maximal` have no order between them. fn maximals(&self) -> impl Iterator; - fn do_merge(&mut self, other: Self); - - fn maximal_times<'a>(&'a self) -> impl Iterator + 'a - where Self: sealed::Seal { - self.maximals().map(|(t, _)| t) - } - - fn merge_view(&mut self, view: HistoryView) - where Self: sealed::Seal { - self.merge(view.into_history()); - } - /// Merge two [`History`] /// /// Note that if there are `maximal` that have an order, the smaller one @@ -92,6 +80,13 @@ where *self = res; } + fn do_merge(&mut self, other: Self); + + fn maximal_times<'a>(&'a self) -> impl Iterator + 'a + where Self: sealed::Seal { + self.maximals().map(|(t, _)| t) + } + /// Check if a [`History`] is greater or equal to a given time. /// /// In other word, if there is a [`Time`] in this history that is greater or diff --git a/src/list/raxos/protocal/src/commonly_used/history/linear.rs b/src/list/raxos/protocal/src/commonly_used/history/linear.rs index 4e872f3..39ac6c6 100644 --- a/src/list/raxos/protocal/src/commonly_used/history/linear.rs +++ b/src/list/raxos/protocal/src/commonly_used/history/linear.rs @@ -4,8 +4,8 @@ use crate::apaxos::history::History; use crate::Types; pub type Mode = bool; -pub const SINGLE_LOG: Mode = false; -pub const MULTI_LOG: Mode = true; +pub const SINGLE_VALUE: Mode = false; +pub const MULTI_VALUE: Mode = true; #[derive(Clone, Debug)] pub struct LinearHistory { @@ -43,22 +43,22 @@ where T::Time: Ord, { fn do_append(&mut self, time: T::Time, event: T::Event) { - // In a single log mode, it disallows to append new event if there is already - // one. Because the history can not be changed. + // In a single value mode(such as classic paxos), + // it disallows to append new event if there is already one. + // Because the history can not be changed. // In such case, just use the last value. - match MODE { - SINGLE_LOG => { - if let Some(last) = self.time_events.last_key_value() { - let v = last.1.clone(); - self.time_events.insert(time, v); + let ev = match MODE { + SINGLE_VALUE => { + if let Some((_t, ev)) = self.time_events.last_key_value() { + ev.clone() } else { - self.time_events.insert(time, event); + event } } - MULTI_LOG => { - self.time_events.insert(time, event); - } - } + MULTI_VALUE => event, + }; + + self.time_events.insert(time, ev); } fn get(&self, time: &T::Time) -> Option<&T::Event> { diff --git a/src/list/raxos/protocal/src/implementations/paxos.rs b/src/list/raxos/protocal/src/implementations/paxos.rs index 5d67b1a..c2604b2 100644 --- a/src/list/raxos/protocal/src/implementations/paxos.rs +++ b/src/list/raxos/protocal/src/implementations/paxos.rs @@ -8,7 +8,7 @@ //! the one with max `v_ballot`. use crate::commonly_used::history::linear::LinearHistory; -use crate::commonly_used::history::linear::SINGLE_LOG; +use crate::commonly_used::history::linear::SINGLE_VALUE; use crate::commonly_used::quorum_set::majority::Majority; use crate::commonly_used::transport::DirectCall; use crate::Types; @@ -20,9 +20,9 @@ struct Paxos {} impl Types for Paxos { type Time = u64; type Event = String; - type History = LinearHistory; - type QuorumSet = Majority; - type Transport = DirectCall; + type History = LinearHistory; + type QuorumSet = Majority; + type Transport = DirectCall; } #[cfg(test)]