Populate discovery from node table

This commit is contained in:
arkpar
2016-02-15 20:28:27 +01:00
parent 4b9c7f7517
commit 01a83e6031
3 changed files with 17 additions and 2 deletions

View File

@@ -110,12 +110,20 @@ impl Discovery {
}
}
pub fn add_node(&mut self, e: NodeEntry) {
/// Add a new node to discovery table. Pings the node.
pub fn add_node(&mut self, e: NodeEntry) {
let endpoint = e.endpoint.clone();
self.update_node(e);
self.ping(&endpoint);
}
/// Add a list of known nodes to the table.
pub fn init_node_list(&mut self, mut nodes: Vec<NodeEntry>) {
for n in nodes.drain(..) {
self.update_node(n);
}
}
fn update_node(&mut self, e: NodeEntry) {
trace!(target: "discovery", "Inserting {:?}", &e);
let ping = {