-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
M src/list/raxos/protocal/src/apaxos/acceptor.rs
- Loading branch information
1 parent
99dcf86
commit d6acaa3
Showing
10 changed files
with
97 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use crate::apaxos::history::History; | ||
use crate::Types; | ||
|
||
/// Represents a snapshot view of a [`History`] up to a specific time. | ||
/// | ||
/// This trait extends the [`History`] trait to represent a subset of the | ||
/// history that includes all time and events **before or equal** a specific | ||
/// "view time". | ||
/// | ||
/// This trait is used by a [`Proposer`] to represent the system state it sees. | ||
pub trait HistoryView<T: Types, H> | ||
where H: History<T> | ||
{ | ||
/// Returns the "current" time of this snapshot view. | ||
/// | ||
/// This time represents the **greatest** single time. | ||
/// All events in the snapshot are causally prior to or concurrent with this | ||
/// time. | ||
/// | ||
/// Note: The current time does not necessarily have to be an actual event | ||
/// time present in this History. It can be any valid time that defines | ||
/// the causal "cut" for this snapshot view. | ||
fn current_time(&self) -> T::Time; | ||
|
||
/// Attempts to append an [`Event`] at the current time to create a new | ||
/// [`History`]. | ||
/// | ||
/// The created new [`History`] instance that includes all | ||
/// events from this view, plus the new event at the current view time. | ||
/// | ||
/// This method should return an `Err` if there is already an [`Event`] at | ||
/// the ([`current_time()`](Self::current_time)). | ||
fn append(self, event: T::Event) -> Result<H, H>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
pub mod acceptor; | ||
pub mod errors; | ||
pub mod greater_equal; | ||
pub mod greater_equal_map; | ||
pub mod history; | ||
pub mod history_view; | ||
pub mod proposal; | ||
pub mod proposer; | ||
pub mod ptime; | ||
|
||
pub mod errors; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use crate::apaxos::history::History; | ||
use crate::apaxos::history_view::HistoryView; | ||
use crate::Types; | ||
|
||
pub struct BasicView<T, H> | ||
where | ||
T: Types, | ||
H: History<T>, | ||
{ | ||
current_time: T::Time, | ||
history: H, | ||
} | ||
|
||
impl<T, H> HistoryView<T, H> for BasicView<T, H> | ||
where | ||
T: Types, | ||
H: History<T>, | ||
{ | ||
fn current_time(&self) -> T::Time { | ||
self.current_time | ||
} | ||
|
||
fn append(self, event: T::Event) -> Result<H, H> { | ||
let mut history = self.history; | ||
history.do_merge(H::new().append(self.current_time, event)); | ||
history | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters