From 32aea0cbf9a1a78ce611903f419ce1ae2b5bca3b Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Mon, 21 Oct 2019 15:16:28 -0400 Subject: [PATCH] Add useful docstrings --- zebra-network/src/constants.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/zebra-network/src/constants.rs b/zebra-network/src/constants.rs index f90e02f6..183ce60d 100644 --- a/zebra-network/src/constants.rs +++ b/zebra-network/src/constants.rs @@ -9,7 +9,16 @@ use crate::protocol::types::*; pub const REQUEST_TIMEOUT: Duration = Duration::from_secs(10); /// We expect to receive a message from a live peer at least once in this time duration. -// XXX this needs to be synchronized with the ping transmission times. +/// +/// This is the sum of: +/// - the interval between connection heartbeats +/// - the timeout of a possible pending (already-sent) request +/// - the timeout for a possible queued request +/// - the timeout for the heartbeat request itself +/// +/// This avoids explicit synchronization, but relies on the peer +/// connector actually setting up channels and these heartbeats in a +/// specific manner that matches up with this math. pub const LIVE_PEER_DURATION: Duration = Duration::from_secs(60 + 10 + 10 + 10); /// Regular interval for sending keepalive `Ping` messages to each @@ -39,6 +48,9 @@ mod tests { use super::*; + /// This assures that the `Duration` value we are computing for + /// LIVE_PEER_DURATION actually matches the other const values it + /// relies on. #[test] fn ensure_live_peer_duration_value_matches_others() { let constructed_live_peer_duration =