Skip to content

Commit

Permalink
Merge pull request #23 from andreev-io/ilya/mismatch-index-none
Browse files Browse the repository at this point in the history
Addressing mismatch_index being None
  • Loading branch information
andreev-io authored Dec 1, 2021
2 parents 15ab077 + 01bc498 commit 0e84c50
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion little_raft/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
description = "The lightest distributed consensus library. Run your own replicated state machine!"
name = "little_raft"
version = "0.1.4"
version = "0.1.5"
authors = ["Ilya Andreev <[email protected]>"]
edition = "2018"
license = "MIT"
Expand Down
9 changes: 5 additions & 4 deletions little_raft/src/replica.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,11 @@ where
// to the Raft paper's guidance on decreasing next_index by
// one at a time, but is more performant in cases when we
// can cut straight to the follower's last_index+1.
let mismatch_index = mismatch_index.unwrap();
if mismatch_index < self.next_index[&from_id] {
let next_index = cmp::min(mismatch_index, last_index + 1);
self.next_index.insert(from_id, next_index);
if let Some(mismatch_index) = mismatch_index {
if mismatch_index < self.next_index[&from_id] {
let next_index = cmp::min(mismatch_index, last_index + 1);
self.next_index.insert(from_id, next_index);
}
}
}
}
Expand Down

0 comments on commit 0e84c50

Please sign in to comment.