summaryrefslogtreecommitdiffstats
path: root/src/state/host.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/state/host.rs')
-rw-r--r--src/state/host.rs30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/state/host.rs b/src/state/host.rs
index f6c460d..6eab803 100644
--- a/src/state/host.rs
+++ b/src/state/host.rs
@@ -29,7 +29,7 @@ impl AppState {
// Tell peers about the new epoch now instead of with the next keepalive (up to a
// keepalive interval later). Ready peers already on it learn it from our sync
- // opening, which goes out right away; everyone else gets a PING, so peers that
+ // opening, which goes out right away; everyone else gets a STATUS, so peers that
// never saw the commit start catching up (we don't sync with them, so nothing
// else would tell them).
let local = self.local_epoch();
@@ -52,7 +52,7 @@ impl AppState {
}
for id in announce {
- if let Err(error) = crate::swarm::peer::send_ping(self, id).await {
+ if let Err(error) = crate::swarm::peer::send_status(self, id).await {
debug!(peer = %id, error = %format!("{error:#}"), "Epoch announcement failed");
}
}
@@ -161,14 +161,24 @@ impl Host for AppState {
fn resume(&self) -> impl Future<Output = ()> + Send {
let state = self.clone();
async move {
- let mut lifecycle = state.lifecycle.write().await;
- if let NodeLifecycle::Joining {
- discovered_swarm_id: Some(swarm_id),
- } = &*lifecycle
- {
- let swarm_id = swarm_id.clone();
- debug!(swarm_id = %swarm_id, "Node resumed");
- *lifecycle = NodeLifecycle::Ready { swarm_id };
+ let resumed = {
+ let mut lifecycle = state.lifecycle.write().await;
+ let swarm_id = match &*lifecycle {
+ NodeLifecycle::Joining {
+ discovered_swarm_id: Some(swarm_id),
+ } => Some(swarm_id.clone()),
+ _ => None,
+ };
+ if let Some(swarm_id) = &swarm_id {
+ debug!(swarm_id = %swarm_id, "Node resumed");
+ *lifecycle = NodeLifecycle::Ready {
+ swarm_id: swarm_id.clone(),
+ };
+ }
+ swarm_id.is_some()
+ };
+ if resumed {
+ crate::swarm::peer::announce(&state);
}
}
}