Struct Learner

Source
pub struct Learner<T> {
    pub id: u64,
    pub messenger: Option<Box<dyn Messenger<T>>>,
    pub last_accepted_n: u64,
    pub accepted_received: HashMap<u64, HashSet<AcceptedData<T>>>,
    pub value: Option<Arc<T>>,
    pub quorum: u8,
}
Expand description

Learners act as the replication factor for the protocol. Once a Client request has been agreed on by the Acceptors, the Learner may take action (i.e.: execute the request and send a response to the client). To improve availability of processing, additional Learners can be added.

Fields§

§id: u64

Proposer’s ID

§messenger: Option<Box<dyn Messenger<T>>>

Messenger specifying communication with other nodes

§last_accepted_n: u64

The last proposal that was accepted

§accepted_received: HashMap<u64, HashSet<AcceptedData<T>>>

Accepted messages received (proposal_n => data)

§value: Option<Arc<T>>

The last accepted value

§quorum: u8

Quorum size

Implementations§

Source§

impl<T> Learner<T>
where T: Hash + Eq,

Source

pub fn new(id: u64, quorum: u8) -> Self

Source

pub fn receive_accepted(&mut self, msg: Message<T>)

Receives an Accepted message from an Acceptor.

Auto Trait Implementations§

§

impl<T> Freeze for Learner<T>

§

impl<T> !RefUnwindSafe for Learner<T>

§

impl<T> !Send for Learner<T>

§

impl<T> !Sync for Learner<T>

§

impl<T> Unpin for Learner<T>

§

impl<T> !UnwindSafe for Learner<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.