udpate
This commit is contained in:
parent
249cead13e
commit
0b33615979
|
@ -23,11 +23,7 @@ impl Default for Node {
|
||||||
|
|
||||||
impl Node {
|
impl Node {
|
||||||
pub fn new(id: [u64; 8], weight: u64, addr: SocketAddr) -> Node {
|
pub fn new(id: [u64; 8], weight: u64, addr: SocketAddr) -> Node {
|
||||||
Node {
|
Node { id, weight, addr }
|
||||||
id: id,
|
|
||||||
weight: weight,
|
|
||||||
addr: addr,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fn key(&self) -> i64 {
|
fn key(&self) -> i64 {
|
||||||
(self.weight as i64).checked_neg().unwrap()
|
(self.weight as i64).checked_neg().unwrap()
|
||||||
|
@ -80,9 +76,7 @@ impl Subscribers {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub fn insert(&mut self, ns: &[Node]) {
|
pub fn insert(&mut self, ns: &[Node]) {
|
||||||
for n in ns.into_iter() {
|
self.data.extend_from_slice(ns);
|
||||||
self.data.push(n.clone());
|
|
||||||
}
|
|
||||||
self.data.sort_by_key(Node::key);
|
self.data.sort_by_key(Node::key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue