p2pool: prevent deleting [0] node_vec and [panic!]

This commit is contained in:
hinto-janaiyo 2022-11-14 22:10:19 -05:00
parent 9faf0fc9f5
commit 4564070d92
No known key found for this signature in database
GPG key ID: D7483F6CA27D1B1D

View file

@ -302,7 +302,12 @@ impl P2pool {
let mut n = 0;
for (name, _) in node_vec.iter() {
if *name == self.selected_name {
self.selected_name = node_vec[n-1].0.clone();
// If deleting [0], make selected = [1]
// instead of attempting to [0-1] (panic!)
match n {
0 => self.selected_name = node_vec[1].0.clone(),
_ => self.selected_name = node_vec[n-1].0.clone(),
};
node_vec.remove(n);
break
}