diff --git a/src/raft.rs b/src/raft.rs index acee1bc5..58f359d7 100644 --- a/src/raft.rs +++ b/src/raft.rs @@ -3036,4 +3036,28 @@ impl Raft { pr.ins.set_cap(cap); } } + + /// Whether this RawNode is active recently. + #[inline] + pub fn is_recent_active(&self, id: u64) -> bool { + self.prs().get(id).map_or(false, |pr| pr.recent_active) + } + + /// Get the next idx of peer. + #[inline] + pub fn get_next_idx(&self, id: u64) -> Option { + self.prs().get(id).map(|pr| pr.next_idx) + } + + /// Get the matched of peer. + #[inline] + pub fn get_matched(&self, id: u64) -> Option { + self.prs().get(id).map(|pr| pr.matched) + } + + /// Determine whether a progress is in Replicate state. + #[inline] + pub fn is_replicating(&self, id: u64) -> bool { + self.prs().get(id).map_or(false, |pr| pr.is_replicating()) + } } diff --git a/src/tracker/progress.rs b/src/tracker/progress.rs index 2f86f5a7..432e0d55 100644 --- a/src/tracker/progress.rs +++ b/src/tracker/progress.rs @@ -203,6 +203,12 @@ impl Progress { true } + /// Determine whether progress is in the Replicate state; + #[inline] + pub fn is_replicating(&self) -> bool { + self.state == ProgressState::Replicate + } + /// Determine whether progress is paused. #[inline] pub fn is_paused(&self) -> bool {