Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Fullstop000 <[email protected]>
  • Loading branch information
Fullstop000 committed Jun 14, 2020
1 parent 987fa7a commit 3c696b1
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/raw_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,6 @@ impl<T: Storage> RawNode<T> {
}

fn commit_ready(&mut self, rd: Ready) {
// If entries were applied (or a snapshot), update our cursor for
// the next Ready. Note that if the current HardState contains a
// new Commit index, this does not mean that we're also applying
// all of the new entries due to commit pagination by size.
let index = rd.applied_cursor();
if index > 0 {
self.advance_apply(index);
}
if rd.ss.is_some() {
self.prev_ss = rd.ss.unwrap();
}
Expand Down Expand Up @@ -427,7 +419,21 @@ impl<T: Storage> RawNode<T> {
/// Advance notifies the RawNode that the application has applied and saved progress in the
/// last Ready results.
pub fn advance(&mut self, rd: Ready) {
self.commit_ready(rd);
// If entries were applied (or a snapshot), update our cursor for
// the next Ready. Note that if the current HardState contains a
// new Commit index, this does not mean that we're also applying
// all of the new entries due to commit pagination by size.
let index = rd.applied_cursor();
if index > 0 {
self.advance_apply(index)
}
self.advance_append(rd);
}

/// Appends and commits the ready value.
#[inline]
pub fn advance_append(&mut self, rd: Ready) {
self.commit_ready(rd)
}

/// Advance apply to the passed index.
Expand Down

0 comments on commit 3c696b1

Please sign in to comment.