Make stake sorting more deterministic for data plane
This commit is contained in:
parent
82c759b6cb
commit
ee83a2ac29
|
@ -373,8 +373,14 @@ impl ClusterInfo {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|c| (*stakes.get(&c.id).unwrap_or(&0), c.clone()))
|
.map(|c| (*stakes.get(&c.id).unwrap_or(&0), c.clone()))
|
||||||
.collect();
|
.collect();
|
||||||
peers_with_stakes.sort_unstable();
|
peers_with_stakes.sort_unstable_by(|(l_stake, l_info), (r_stake, r_info)| {
|
||||||
peers_with_stakes.reverse();
|
if r_stake == l_stake {
|
||||||
|
r_info.id.cmp(&l_info.id)
|
||||||
|
} else {
|
||||||
|
r_stake.cmp(&l_stake)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
peers_with_stakes.dedup();
|
||||||
peers_with_stakes
|
peers_with_stakes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue