From 86bdb1af27a3dffc13f209e22417a98944e1dec6 Mon Sep 17 00:00:00 2001 From: jack Date: Tue, 26 Aug 2025 12:17:23 +0200 Subject: [PATCH] =?UTF-8?q?Relay:=20increase=20broadcast=20TTL=20cap=20in?= =?UTF-8?q?=20sparse=20graphs=20to=206;=20tighten=20jitter=20for=20handsha?= =?UTF-8?q?ke=20(10=E2=80=9335ms)=20and=20directed=20(20=E2=80=9360ms)=20r?= =?UTF-8?q?elays?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bitchat/Services/RelayController.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bitchat/Services/RelayController.swift b/bitchat/Services/RelayController.swift index 661772a6..aec4adb0 100644 --- a/bitchat/Services/RelayController.swift +++ b/bitchat/Services/RelayController.swift @@ -25,7 +25,8 @@ struct RelayController { // Always relay with no TTL cap for these types let newTTL = (ttl &- 1) // Slight jitter to desynchronize without adding too much latency - let delayRange: ClosedRange = isHandshake ? 20...60 : 40...120 + // Tighter for faster multi-hop handshakes and directed DMs + let delayRange: ClosedRange = isHandshake ? 10...35 : 20...60 let delayMs = Int.random(in: delayRange) return RelayDecision(shouldRelay: true, newTTL: newTTL, delayMs: delayMs) } @@ -42,8 +43,10 @@ struct RelayController { let prob = baseProb let shouldRelay = Double.random(in: 0...1) <= prob - // TTL clamping in dense graphs (only for broadcast) - let ttlCap: UInt8 = degree >= highDegreeThreshold ? 3 : 5 + // TTL clamping for broadcast + // - Dense graphs: keep very low to avoid floods + // - Sparse graphs: allow slightly longer reach for multi-hop discovery + let ttlCap: UInt8 = degree >= highDegreeThreshold ? 3 : 6 let clamped = max(1, min(ttl, ttlCap)) let newTTL = clamped &- 1