Compare commits

..

No commits in common. "ac1aec9d25c9a5ea5ac939155346a2feed90d3e3" and "bd839534e01f40189ed0739c2a19b4ebe3ae2f87" have entirely different histories.

2 changed files with 9 additions and 24 deletions

View File

@ -339,10 +339,9 @@ impl<D: Device, P: Protocol, S: Socket, TS: TimeSource> GenericCloud<D, P, S, TS
} }
} }
for addr in del { for addr in del {
self.peers.remove(&addr);
self.pending_inits.remove(&addr); self.pending_inits.remove(&addr);
if self.peers.remove(&addr).is_some() { self.connect_sock(addr)?;
self.connect_sock(addr)?;
}
} }
Ok(()) Ok(())
} }
@ -717,24 +716,14 @@ impl<D: Device, P: Protocol, S: Socket, TS: TimeSource> GenericCloud<D, P, S, TS
let msg_result = if let Some(init) = self.pending_inits.get_mut(&src) { let msg_result = if let Some(init) = self.pending_inits.get_mut(&src) {
init.handle_message(data) init.handle_message(data)
} else if is_init_message(data.message()) { } else if is_init_message(data.message()) {
let mut result = None; let mut init = self.crypto.peer_instance(self.create_node_info());
if let Some(peer) = self.peers.get_mut(&src) { let msg_result = init.handle_message(data);
if peer.crypto.has_init() { match msg_result {
result = Some(peer.crypto.handle_message(data)) Ok(res) => {
} self.pending_inits.insert(src, init);
} Ok(res)
if let Some(result) = result {
result
} else {
let mut init = self.crypto.peer_instance(self.create_node_info());
let msg_result = init.handle_message(data);
match msg_result {
Ok(res) => {
self.pending_inits.insert(src, init);
Ok(res)
}
Err(err) => return Err(err)
} }
Err(err) => return Err(err)
} }
} else if let Some(peer) = self.peers.get_mut(&src) { } else if let Some(peer) = self.peers.get_mut(&src) {
peer.crypto.handle_message(data) peer.crypto.handle_message(data)

View File

@ -269,10 +269,6 @@ impl<P: Payload> PeerCrypto<P> {
} }
} }
pub fn has_init(&self) -> bool {
self.init.is_some()
}
pub fn is_ready(&self) -> bool { pub fn is_ready(&self) -> bool {
self.core.is_some() self.core.is_some()
} }