diff --git a/SignalServiceKit/src/Loki/API/LokiAPI+SwarmAPI.swift b/SignalServiceKit/src/Loki/API/LokiAPI+SwarmAPI.swift index da761171a..a6b8e53da 100644 --- a/SignalServiceKit/src/Loki/API/LokiAPI+SwarmAPI.swift +++ b/SignalServiceKit/src/Loki/API/LokiAPI+SwarmAPI.swift @@ -121,7 +121,7 @@ public extension LokiAPI { internal extension Promise { internal func handlingSwarmSpecificErrorsIfNeeded(for target: LokiAPITarget, associatedWith hexEncodedPublicKey: String) -> Promise { - return recover(on: DispatchQueue.global()) { error -> Promise in + return recover(on: LokiAPI.errorHandlingQueue) { error -> Promise in if let error = error as? NetworkManagerError { switch error.statusCode { case 0, 400, 500, 503: @@ -130,7 +130,6 @@ internal extension Promise { let newFailureCount = oldFailureCount + 1 LokiAPI.failureCount[target] = newFailureCount print("[Loki] Couldn't reach snode at: \(target); setting failure count to \(newFailureCount).") - Analytics.shared.track("Unreachable Snode") if newFailureCount >= LokiAPI.failureThreshold { print("[Loki] Failure threshold reached for: \(target); dropping it.") LokiAPI.dropIfNeeded(target, hexEncodedPublicKey: hexEncodedPublicKey) // Remove it from the swarm cache associated with the given public key @@ -140,7 +139,6 @@ internal extension Promise { case 421: // The snode isn't associated with the given public key anymore print("[Loki] Invalidating swarm for: \(hexEncodedPublicKey).") - Analytics.shared.track("Migrated Snode") LokiAPI.dropIfNeeded(target, hexEncodedPublicKey: hexEncodedPublicKey) case 432: // The PoW difficulty is too low diff --git a/SignalServiceKit/src/Loki/API/LokiAPI.swift b/SignalServiceKit/src/Loki/API/LokiAPI.swift index 2fb7e325c..5cacc70c4 100644 --- a/SignalServiceKit/src/Loki/API/LokiAPI.swift +++ b/SignalServiceKit/src/Loki/API/LokiAPI.swift @@ -5,6 +5,7 @@ public final class LokiAPI : NSObject { private static var syncMessageTimestamps: [String:Set] = [:] public static var lastDeviceLinkUpdate: [String:Date] = [:] // Hex encoded public key to date @objc public static var userHexEncodedPublicKeyCache: [String:Set] = [:] // Thread ID to set of user hex encoded public keys + public static let errorHandlingQueue = DispatchQueue(label: "errorHandlingQueue") // MARK: Convenience internal static let storage = OWSPrimaryStorage.shared() diff --git a/SignalServiceKit/src/Loki/API/LokiLongPoller.swift b/SignalServiceKit/src/Loki/API/LokiLongPoller.swift index 2dc171881..d645ba7e6 100644 --- a/SignalServiceKit/src/Loki/API/LokiLongPoller.swift +++ b/SignalServiceKit/src/Loki/API/LokiLongPoller.swift @@ -69,7 +69,7 @@ public final class LokiLongPoller : NSObject { let nextSnode = unusedSnodes.randomElement()! usedSnodes.insert(nextSnode) print("[Loki] Opening long polling connection to \(nextSnode).") - longPoll(nextSnode, seal: seal).catch(on: DispatchQueue.global()) { [weak self] error in + longPoll(nextSnode, seal: seal).catch(on: LokiAPI.errorHandlingQueue) { [weak self] error in print("[Loki] Long polling connection to \(nextSnode) failed; dropping it and switching to next snode.") LokiAPI.dropIfNeeded(nextSnode, hexEncodedPublicKey: userHexEncodedPublicKey) self?.openConnectionToNextSnode(seal: seal)