aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/peer/inbound.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/swarm/peer/inbound.rs')
-rw-r--r--src/swarm/peer/inbound.rs24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/swarm/peer/inbound.rs b/src/swarm/peer/inbound.rs
index d4df6c7..b4a96e4 100644
--- a/src/swarm/peer/inbound.rs
+++ b/src/swarm/peer/inbound.rs
@@ -4,14 +4,16 @@ use std::time::Duration;
use anyhow::{Result, anyhow, bail};
use tokio::time::Instant;
-use tracing::{debug, info, warn};
+use tracing::{debug, warn};
use super::admit::admit;
use super::epoch::observe_peer_epoch;
use super::handshake::{
discover_peers, ensure_handshake, establish_peer, peer_swarm, remember_peer, send_hello_reply,
};
-use super::keepalive::{heal_if_diverged, local_status, note_alive, note_status, status_received};
+use super::keepalive::{
+ heal_if_diverged, heard_from, local_status, note_alive, note_status, status_received,
+};
use super::lanes::SyncLanes;
use crate::state::AppState;
use crate::swarm::sync::SyncEvent;
@@ -58,21 +60,9 @@ pub(crate) async fn handle_message(
// Any inbound message proves liveness. When we heard from it before tells a
// restarted peer how long it was away (in our HELLO_REPLY).
- let (reactivated, previously_seen) = {
- let peer_state_mutex = state.get_or_create_peer_state(&peer).await;
- let mut peer_state = peer_state_mutex.lock().await;
- let previously_seen = peer_state.last_seen;
- if peer_state.unreachable_since.is_some() {
- // Reachable again (`mark_seen` clears it).
- state.topology_changed.notify_one();
- }
- (peer_state.mark_seen(Instant::now()), previously_seen)
- };
- crate::swarm::source::heard_from(state, &peer);
-
- if reactivated {
- info!(peer = %peer, "Dormant peer is active again; re-handshaking");
- }
+ let peer_state = state.get_or_create_peer_state(&peer).await;
+ let (reactivated, previously_seen) =
+ heard_from(state, &peer, &peer_state, Instant::now(), |_| {}).await;
let run = match &message {
transport::ParsedMessage::Hello(hello) => Some(hello.run_id),