From 08d3123c46a1fd73fde86b69677081a46c59eebc Mon Sep 17 00:00:00 2001 From: Rui Date: Thu, 24 Oct 2024 15:49:57 -0700 Subject: [PATCH] Reduce the unnecessary network reconnects --- build.gradle.kts | 2 +- .../state/v2/manager/AsyncAbacusStateManagerV2.kt | 9 ++++++--- v4_abacus.podspec | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3dcdeae58..8be4d821a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -52,7 +52,7 @@ allprojects { } group = "exchange.dydx.abacus" -version = "1.13.12" +version = "1.13.13" repositories { google() diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/manager/AsyncAbacusStateManagerV2.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/manager/AsyncAbacusStateManagerV2.kt index bf635e7bc..2b7ecfea4 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/manager/AsyncAbacusStateManagerV2.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/manager/AsyncAbacusStateManagerV2.kt @@ -89,8 +89,8 @@ class AsyncAbacusStateManagerV2( private var environments: IList = iListOf() set(value) { - field = value - ioImplementations.threading?.async(ThreadingType.abacus) { + if (field != value) { + field = value _environment = findEnvironment(environmentId) ioImplementations.threading?.async(ThreadingType.main) { stateNotification?.environmentsChanged() @@ -117,8 +117,11 @@ class AsyncAbacusStateManagerV2( private var _environment: V4Environment? = null set(value) { if (field !== value) { + val shouldReconnect = field?.id != value?.id field = value - reconnect() + if (shouldReconnect) { + reconnect() + } } } diff --git a/v4_abacus.podspec b/v4_abacus.podspec index 60af2e47b..531a89995 100644 --- a/v4_abacus.podspec +++ b/v4_abacus.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'v4_abacus' - spec.version = '1.13.12' + spec.version = '1.13.13' spec.homepage = 'https://github.com/dydxprotocol/v4-abacus' spec.source = { :http=> ''} spec.authors = ''