Skip to content

Commit

Permalink
Renames
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoverbear committed Nov 14, 2018
1 parent 184fb27 commit 461a375
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ impl ProgressSet {
);
}

/// Returns the minimal committed index for the cluster.
/// Returns the maximal committed index for the cluster.
///
/// Eg. If the matched indexes are [2,2,2,4,5], it will return 2.
pub fn minimum_committed_index(&self) -> u64 {
pub fn maximal_committed_index(&self) -> u64 {
let mut matched = self.sort_buffer.borrow_mut();
matched.clear();
self.voters().for_each(|(_id, peer)| {
Expand Down
8 changes: 4 additions & 4 deletions src/raft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ impl<T: Storage> Raft<T> {
/// Attempts to advance the commit index. Returns true if the commit index
/// changed (in which case the caller should call `r.bcast_append`).
pub fn maybe_commit(&mut self) -> bool {
let mci = self.prs().minimum_committed_index();
let mci = self.prs().maximal_committed_index();
self.raft_log.maybe_commit(mci, self.term)
}

Expand Down Expand Up @@ -778,7 +778,7 @@ impl<T: Storage> Raft<T> {
"{} received {:?} from {} at term {}",
self.id, vote_msg, self_id, self.term
);
self.poll(self_id, acceptance);
self.register_vote(self_id, acceptance);
if let CandidacyStatus::Elected = self.prs().candidacy_status(self.id, &self.votes) {
// We won the election after voting for ourselves (which must mean that
// this is a single-node cluster). Advance to the next state.
Expand Down Expand Up @@ -818,7 +818,7 @@ impl<T: Storage> Raft<T> {
}

/// Sets the vote of `id` to `vote`.
fn poll(&mut self, id: u64, vote: bool) {
fn register_vote(&mut self, id: u64, vote: bool) {
self.votes.entry(id).or_insert(vote);
}

Expand Down Expand Up @@ -1517,7 +1517,7 @@ impl<T: Storage> Raft<T> {
from_id,
self.term
);
self.poll(from_id, acceptance);
self.register_vote(from_id, acceptance);
match self.prs().candidacy_status(self.id, &self.votes) {
CandidacyStatus::Elected => {
if self.state == StateRole::PreCandidate {
Expand Down

0 comments on commit 461a375

Please sign in to comment.