diff options
| author | tv <tv@krebsco.de> | 2026-11-03 02:43:15 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-03 02:43:15 +0100 |
| commit | 5cd26d321b706113afb8431aba35ab8fb32281c4 (patch) | |
| tree | ae1a64479a29182c44a2375417f74583e4ee074a /src/swarm/peer/keepalive.rs | |
| parent | e4709cc6ab3fca7f7ce40793aa5cceb64f0bfea3 (diff) | |
announcements answered only if heads differ
Diffstat (limited to 'src/swarm/peer/keepalive.rs')
| -rw-r--r-- | src/swarm/peer/keepalive.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/swarm/peer/keepalive.rs b/src/swarm/peer/keepalive.rs index 8597dcd..196b8b6 100644 --- a/src/swarm/peer/keepalive.rs +++ b/src/swarm/peer/keepalive.rs @@ -32,6 +32,20 @@ pub(crate) async fn send_status(state: &AppState, peer: &str) -> Result<()> { .await } +/// Sends `peer` a STATUS announcing our new heads (`swarm::relay`): no keepalive, so it +/// leaves the keepalives' schedule as it is, and it is answered only if the peer's heads +/// differ (`Status::announcing`). +pub(crate) async fn announce_heads(state: &AppState, peer: &str) -> Result<()> { + let status = transport::Status { + announcing: true, + ..local_status(state, peer).await + }; + state + .transport + .send_message(peer, &ParsedMessage::Status(status)) + .await +} + /// Sends `peer` a PING (the paths layer measures the path with it). pub(crate) async fn send_ping(state: &AppState, peer: &str) -> Result<()> { let nonce = crate::transport::paths::random_nonce(); @@ -173,6 +187,7 @@ pub(crate) async fn local_status(state: &AppState, peer: &str) -> transport::Sta ready: state.is_ready().await && !state.is_closing(), syncs_with_you, leaving: state.is_closing(), + announcing: false, } } |
