diff options
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, } } |
