Skip to content

Commit

Permalink
Interface of querying whether two peers are in same broadcast group
Browse files Browse the repository at this point in the history
Signed-off-by: LintianShi <[email protected]>
  • Loading branch information
LintianShi committed Oct 14, 2022
1 parent 0a01106 commit 0cc4fa9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/raft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3215,6 +3215,16 @@ impl<T: Storage> Raft<T> {
}
}

/// Whether two peers are in the same broadcast group.
pub fn is_in_same_broadcast_group(&self, id: u64, id_other: u64) -> bool {
let group_id = self.prs().get(id).map_or(0, |pr| pr.broadcast_group_id);
let other_group_id = self
.prs()
.get(id_other)
.map_or(0, |pr| pr.broadcast_group_id);
group_id != 0 && other_group_id != 0 && group_id == other_group_id
}

// Whether this peer is active recently.
#[inline]
fn is_recent_active(&self, id: u64) -> bool {
Expand Down

0 comments on commit 0cc4fa9

Please sign in to comment.