1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use crate::eraftpb::ConfState;
fn eq_without_order(lhs: &[u64], rhs: &[u64]) -> bool {
for l in lhs {
if !rhs.contains(l) {
return false;
}
}
for r in rhs {
if !lhs.contains(r) {
return false;
}
}
true
}
#[must_use]
pub fn conf_state_eq(lhs: &ConfState, rhs: &ConfState) -> bool {
if lhs.get_voters() == rhs.get_voters()
&& lhs.get_learners() == rhs.get_learners()
&& lhs.get_voters_outgoing() == rhs.get_voters_outgoing()
&& lhs.get_learners_next() == rhs.get_learners_next()
&& lhs.auto_leave == rhs.auto_leave
{
return true;
}
eq_without_order(lhs.get_voters(), rhs.get_voters())
&& eq_without_order(lhs.get_learners(), rhs.get_learners())
&& eq_without_order(lhs.get_voters_outgoing(), rhs.get_voters_outgoing())
&& eq_without_order(lhs.get_learners_next(), rhs.get_learners_next())
&& lhs.auto_leave == rhs.auto_leave
}