From f9ea1270fa3f1a2c3e145f967aeabed088de7f6f Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Fri, 22 Aug 2025 13:35:46 -0400 Subject: [PATCH] creates a separate okhttp for relays --- .../java/com/vitorpamplona/amethyst/Amethyst.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt index 9101a08fb..fe960b6d1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt @@ -82,7 +82,7 @@ class Amethyst : Application() { // Service that will run at all times to receive events from Pokey val pokeyReceiver = PokeyReceiver() - // creates okHttpClients based on the conditions of the connection and tor status + // manages all the other connections separately from relays. val okHttpClients = DualHttpClientManager( userAgent = appAgent, @@ -92,12 +92,22 @@ class Amethyst : Application() { scope = applicationIOScope, ) + // manages all relay connections + val okHttpClientForRelays = + DualHttpClientManager( + userAgent = appAgent, + proxyPortProvider = torManager.activePortOrNull, + isMobileDataProvider = connManager.isMobileOrNull, + keyCache = keyCache, + scope = applicationIOScope, + ) + val torProxySettingsAnchor = ProxySettingsAnchor() // Connects the NostrClient class with okHttp val websocketBuilder = OkHttpWebSocket.Builder { url -> - okHttpClients.getHttpClient(torProxySettingsAnchor.useProxy(url)) + okHttpClientForRelays.getHttpClient(torProxySettingsAnchor.useProxy(url)) } // Caches all events in Memory