pub struct Proposer<T> {
pub id: u64,
pub messenger: Option<Box<dyn Messenger<T>>>,
pub value: Option<Arc<T>>,
pub proposal_n: u64,
pub last_accepted_n: u64,
pub promises_received: HashMap<u64, HashSet<PromiseData<T>>>,
pub accepted_received: HashMap<u64, HashSet<AcceptedData<T>>>,
pub quorum: u8,
}
Expand description
A Proposer advocates a client request, attempting to convince the Acceptors to agree on it, and acting as a coordinator to move the protocol forward when conflicts occur.
Fields§
§id: u64
Proposer
’s ID
messenger: Option<Box<dyn Messenger<T>>>
Messenger
specifying communication with other nodes
value: Option<Arc<T>>
The proposed value
proposal_n: u64
The highest proposal number seen
last_accepted_n: u64
The last proposal that was accepted
promises_received: HashMap<u64, HashSet<PromiseData<T>>>
Promises received (proposal_n => data)
accepted_received: HashMap<u64, HashSet<AcceptedData<T>>>
Accepted messages received (proposal_n => data)
quorum: u8
The minimum number of Acceptor
s needed to continue
Implementations§
Source§impl<T> Proposer<T>
impl<T> Proposer<T>
Sourcepub fn receive_promise(&mut self, msg: Message<T>)
pub fn receive_promise(&mut self, msg: Message<T>)
Receives a Promise
message from an Acceptor
.
Sourcepub fn accept(&mut self)
pub fn accept(&mut self)
The second phase. Sets a value for the proposal, and builds an Accept
request.
Sourcepub fn receive_accepted(&mut self, msg: Message<T>)
pub fn receive_accepted(&mut self, msg: Message<T>)
Receives an Accepted
message from an Acceptor
.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Proposer<T>
impl<T> !RefUnwindSafe for Proposer<T>
impl<T> !Send for Proposer<T>
impl<T> !Sync for Proposer<T>
impl<T> Unpin for Proposer<T>
impl<T> !UnwindSafe for Proposer<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more