From 292ca4532b46fb2d21e95200199c3c86c60abdf4 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Thu, 30 Oct 2025 13:50:47 +0100 Subject: [PATCH] fix connection attempt counter tracker (#503) --- .../com/bitchat/android/mesh/BluetoothConnectionTracker.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/bitchat/android/mesh/BluetoothConnectionTracker.kt b/app/src/main/java/com/bitchat/android/mesh/BluetoothConnectionTracker.kt index 745a1a39..7029185f 100644 --- a/app/src/main/java/com/bitchat/android/mesh/BluetoothConnectionTracker.kt +++ b/app/src/main/java/com/bitchat/android/mesh/BluetoothConnectionTracker.kt @@ -198,7 +198,8 @@ class BluetoothConnectionTracker( } // Update connection attempt atomically - val attempts = (currentAttempt?.attempts ?: 0) + 1 + // If the previous attempt window expired, reset backoff to 1; otherwise increment + val attempts = if (currentAttempt?.isExpired() == true) 1 else (currentAttempt?.attempts ?: 0) + 1 pendingConnections[deviceAddress] = ConnectionAttempt(attempts) Log.d(TAG, "Tracker: Added pending connection for $deviceAddress (attempts: $attempts)") return true @@ -283,7 +284,6 @@ class BluetoothConnectionTracker( subscribedDevices.removeAll { it.address == deviceAddress } addressPeerMap.remove(deviceAddress) } - pendingConnections.remove(deviceAddress) firstAnnounceSeen.remove(deviceAddress) Log.d(TAG, "Cleaned up device connection for $deviceAddress") }