summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/simtest/mod.rs8
-rw-r--r--src/state.rs6
-rw-r--r--src/swarm/source.rs9
3 files changed, 16 insertions, 7 deletions
diff --git a/src/simtest/mod.rs b/src/simtest/mod.rs
index f0fee02..18975aa 100644
--- a/src/simtest/mod.rs
+++ b/src/simtest/mod.rs
@@ -34,6 +34,9 @@ pub(crate) const KEEPALIVE: Duration = Duration::from_millis(250);
/// First wait for a sync answer before sending again (10 s in production, where large
/// messages take a while): a lost sync message costs a test 1 s, a heal 2 s.
pub(crate) const SYNC_REPLY_TIMEOUT: Duration = Duration::from_secs(1);
+/// How long the simulated net may take to deliver a message: well above its delays.
+/// A catch-up source that stops sending sync messages is given up after this.
+pub(crate) const DELIVERY_LIMIT: Duration = Duration::from_secs(3);
/// A simulated swarm: the net and the nodes started on it.
pub(crate) struct Sim {
@@ -71,7 +74,10 @@ impl Sim {
initial_epoch: Epoch::GENESIS,
initial_doc: AutoCommit::new(),
earlier_actors: Vec::new(),
- timing: Timing::new(KEEPALIVE, SYNC_REPLY_TIMEOUT),
+ timing: Timing {
+ delivery_limit: DELIVERY_LIMIT,
+ ..Timing::new(KEEPALIVE, SYNC_REPLY_TIMEOUT)
+ },
neighbours_k: 8,
alias: Some(id.to_owned()),
electorate_window: Duration::from_secs(30 * 24 * 3600),
diff --git a/src/state.rs b/src/state.rs
index e6054ad..5ec1c5a 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -224,6 +224,8 @@ const SYNC_REPLY_TIMEOUT: Duration = Duration::from_secs(10);
/// Upper bound, as a multiple of the first wait: 5 minutes (Mycelium gives up on a
/// message after five minutes).
const SYNC_REPLY_TIMEOUT_MAX_FACTOR: u32 = 30;
+/// How long Mycelium tries to deliver a message before dropping it.
+const MYCELIUM_DELIVERY_LIMIT: Duration = Duration::from_secs(300);
impl SyncSession {
/// `reply_backoff`: waits for sync answers (`Timing::sync_reply_backoff`).
@@ -533,6 +535,9 @@ pub(crate) struct Timing {
/// First wait for an answer to a sync message before sending again; doubles while
/// answers stay out (`SyncSession::reply_backoff`).
pub(crate) sync_reply_timeout: Duration,
+ /// How long the transport tries to deliver a message before dropping it (Mycelium:
+ /// five minutes): a peer silent for longer has nothing on the way to us any more.
+ pub(crate) delivery_limit: Duration,
}
impl Timing {
@@ -567,6 +572,7 @@ impl Timing {
// Only the source gets these, and only while catching up.
catch_up_probe: (keepalive / 30).clamp(Duration::from_secs(1), Duration::from_secs(5)),
sync_reply_timeout,
+ delivery_limit: MYCELIUM_DELIVERY_LIMIT,
}
}
diff --git a/src/swarm/source.rs b/src/swarm/source.rs
index a8866a6..d5b572a 100644
--- a/src/swarm/source.rs
+++ b/src/swarm/source.rs
@@ -20,7 +20,7 @@
//! big answer lost on the way, a stuck sync state) would keep us catching up forever.
//! So it is also given up after three of our sync messages in a row went unanswered,
//! once nothing from it can still be on the way: no sync message from it for
-//! `MYCELIUM_DELIVERY_LIMIT`, after which Mycelium has delivered or dropped anything it
+//! `Timing::delivery_limit`, after which Mycelium has delivered or dropped anything it
//! sent before. Meanwhile, every minute without a sync message from it is logged as a
//! warning.
@@ -46,10 +46,6 @@ const REFUSALS: u32 = 2;
/// Unanswered sync messages in a row before the source may be given up.
const REPLY_TIMEOUTS: u32 = 3;
-/// How long Mycelium tries to deliver a message before dropping it: a source silent
-/// (in sync) for longer has nothing on the way to us any more.
-const MYCELIUM_DELIVERY_LIMIT: Duration = Duration::from_secs(300);
-
/// How often a stalled catch-up is logged.
const STALL_WARNING: Duration = Duration::from_secs(60);
@@ -170,7 +166,8 @@ pub(crate) fn reply_timed_out(state: &AppState, peer: &str) {
};
current.reply_timeouts += 1;
let silent = current.last_sync.elapsed();
- let give_up = current.reply_timeouts >= REPLY_TIMEOUTS && silent >= MYCELIUM_DELIVERY_LIMIT;
+ let give_up =
+ current.reply_timeouts >= REPLY_TIMEOUTS && silent >= state.timing.delivery_limit;
let timeouts = current.reply_timeouts;
if give_up {
*source = None;