Simplify selection of spare replacement bucket
This commit is contained in:
parent
203b949d43
commit
6462027b7f
|
@ -564,18 +564,15 @@ impl BridgeAuth {
|
|||
bucketnums.push(*bucketnum);
|
||||
}
|
||||
// Get the first spare and remove it from the spares set.
|
||||
let mut spare = *self.bridge_table.spares.iter().next().unwrap();
|
||||
// Check that the first spare in the list of spares is not the one to be replaced
|
||||
if bucketnums.contains(&spare) {
|
||||
// If it is, take the last spare instead
|
||||
spare = *self.bridge_table.spares.iter().last().unwrap();
|
||||
// If this is the same bucketnum, there is only one spare bucket with the bridge
|
||||
// to be replaced in it, so don't replace it.
|
||||
if bucketnums.contains(&spare) {
|
||||
res = ReplaceSuccess::NotReplaced;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
let Some(spare) = self
|
||||
.bridge_table
|
||||
.spares
|
||||
.iter()
|
||||
.find(|x| !bucketnums.contains(x))
|
||||
.cloned()
|
||||
else {
|
||||
return ReplaceSuccess::NotReplaced;
|
||||
};
|
||||
self.bridge_table.spares.remove(&spare);
|
||||
self.bridge_table.recycleable_keys.push(spare);
|
||||
// Get the actual bridges from the spare bucket
|
||||
|
|
Loading…
Reference in New Issue