pub struct VoteValidator;Expand description
Vote request validation
Implementations§
Source§impl VoteValidator
impl VoteValidator
Sourcepub fn should_grant_vote(
receiver_term: Term,
receiver_voted_for: &Option<NodeId>,
receiver_last_log_index: u64,
receiver_last_log_term: Term,
candidate_id: &NodeId,
candidate_term: Term,
candidate_last_log_index: u64,
candidate_last_log_term: Term,
) -> bool
pub fn should_grant_vote( receiver_term: Term, receiver_voted_for: &Option<NodeId>, receiver_last_log_index: u64, receiver_last_log_term: Term, candidate_id: &NodeId, candidate_term: Term, candidate_last_log_index: u64, candidate_last_log_term: Term, ) -> bool
Validate if a vote request should be granted
A vote should be granted if:
- The candidate’s term is at least as current as receiver’s term
- The receiver hasn’t voted in this term, or has voted for this candidate
- The candidate’s log is at least as up-to-date as receiver’s log
Auto Trait Implementations§
impl Freeze for VoteValidator
impl RefUnwindSafe for VoteValidator
impl Send for VoteValidator
impl Sync for VoteValidator
impl Unpin for VoteValidator
impl UnwindSafe for VoteValidator
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