Skip to content

Commit 0cc4fa9

Browse files
author
LintianShi
committed
Interface of querying whether two peers are in same broadcast group
Signed-off-by: LintianShi <lintian.shi@pingcap.com>
1 parent 0a01106 commit 0cc4fa9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/raft.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3215,6 +3215,16 @@ impl<T: Storage> Raft<T> {
32153215
}
32163216
}
32173217

3218+
/// Whether two peers are in the same broadcast group.
3219+
pub fn is_in_same_broadcast_group(&self, id: u64, id_other: u64) -> bool {
3220+
let group_id = self.prs().get(id).map_or(0, |pr| pr.broadcast_group_id);
3221+
let other_group_id = self
3222+
.prs()
3223+
.get(id_other)
3224+
.map_or(0, |pr| pr.broadcast_group_id);
3225+
group_id != 0 && other_group_id != 0 && group_id == other_group_id
3226+
}
3227+
32183228
// Whether this peer is active recently.
32193229
#[inline]
32203230
fn is_recent_active(&self, id: u64) -> bool {

0 commit comments

Comments
 (0)