Spike targeted gossip rebootstrap
This commit is contained in:
@@ -516,6 +516,37 @@ impl RoomState for IrohGossipState {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn rebootstrap_peers(&self, peers: Vec<EndpointAddr>) -> Result<(), NetError> {
|
||||
let self_id = self._endpoint.id();
|
||||
let mut peer_ids = Vec::new();
|
||||
for addr in peers {
|
||||
if addr.id == self_id || peer_ids.contains(&addr.id) {
|
||||
continue;
|
||||
}
|
||||
self.address_lookup.add_endpoint_info(addr.clone());
|
||||
peer_ids.push(addr.id);
|
||||
}
|
||||
|
||||
if peer_ids.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Clone the sender before awaiting: active_sender is a standard mutex and
|
||||
// must never be held across an async gossip operation.
|
||||
let sender = self
|
||||
.active_sender
|
||||
.lock()
|
||||
.unwrap()
|
||||
.clone()
|
||||
.ok_or_else(|| NetError::Other("Not in a room".to_string()))?;
|
||||
|
||||
crate::log_msg(&format!("Rebootstrapping gossip peers: {:?}", peer_ids));
|
||||
sender
|
||||
.join_peers(peer_ids)
|
||||
.await
|
||||
.map_err(|e| NetError::Gossip(e.to_string()))
|
||||
}
|
||||
|
||||
async fn send_chat(&self, text: String) -> Result<(), NetError> {
|
||||
let name = {
|
||||
let guard = self.self_state.lock().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user