From 66d907d1b2085a159497bc06b739b66a76e0f219 Mon Sep 17 00:00:00 2001 From: akwizgran Date: Thu, 19 May 2022 17:24:22 +0100 Subject: [PATCH] Add comment explaining relationship between constants. --- .../briarproject/bramble/plugin/tor/TorPlugin.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bramble-core/src/main/java/org/briarproject/bramble/plugin/tor/TorPlugin.java b/bramble-core/src/main/java/org/briarproject/bramble/plugin/tor/TorPlugin.java index 7b5ba5302..a0b2106f3 100644 --- a/bramble-core/src/main/java/org/briarproject/bramble/plugin/tor/TorPlugin.java +++ b/bramble-core/src/main/java/org/briarproject/bramble/plugin/tor/TorPlugin.java @@ -128,6 +128,19 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener { /** * After this many consecutive successful connections to our own hidden * service we consider the network to be stable. + *

+ * This constant times {@link #POLLING_INTERVAL_UNSTABLE} should be + * greater than {@link #POLLING_INTERVAL_STABLE}. This ensures that if + * we experience a network outage that isn't detected by the + * {@link NetworkManager}, and if one of our contacts comes online during + * the outage, then either the outage lasts longer than + * {@link #POLLING_INTERVAL_STABLE}, in which case we detect the outage + * by failing to connect to our own hidden service, or the outage ends + * before the contact considers their own network connection to be stable, + * in which case the contact is still trying to connect to us when the + * outage ends. Either way, we don't end up in a situation where both we + * and the contact consider our network connections to be stable and stop + * trying to connect to each other, despite both being online. */ private static final int STABLE_NETWORK_THRESHOLD = 10;