diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/datastore/RuntimeDataStore.kt b/core/datasource/src/main/java/com/tangem/datasource/local/datastore/RuntimeDataStore.kt index db39d064d3..69fe8b7ca2 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/local/datastore/RuntimeDataStore.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/local/datastore/RuntimeDataStore.kt @@ -2,10 +2,11 @@ package com.tangem.datasource.local.datastore import com.tangem.datasource.local.datastore.core.StringKeyDataStore import kotlinx.coroutines.flow.* +import java.util.concurrent.ConcurrentHashMap internal class RuntimeDataStore : StringKeyDataStore { - private val store: MutableSharedFlow?> = MutableSharedFlow(replay = 1) + private val store: MutableSharedFlow?> = MutableSharedFlow(replay = 1) init { store.tryEmit(value = null) @@ -61,7 +62,7 @@ internal class RuntimeDataStore : StringKeyDataStore { override suspend fun remove(keys: Collection) { updateValue { value -> - HashMap(value.filterKeys { it !in keys }) + ConcurrentHashMap(value.filterKeys { it !in keys }) } } @@ -69,8 +70,10 @@ internal class RuntimeDataStore : StringKeyDataStore { store.emit(value = null) } - private suspend inline fun updateValue(update: (HashMap) -> HashMap) { - val storedData = store.firstOrNull() ?: hashMapOf() + private suspend inline fun updateValue( + update: (ConcurrentHashMap) -> ConcurrentHashMap, + ) { + val storedData = store.firstOrNull() ?: ConcurrentHashMap() val updatedData = update(storedData) store.emit(updatedData) diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/TokenListSortingOperations.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/TokenListSortingOperations.kt index be9623f89e..fd6ff690a3 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/TokenListSortingOperations.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/TokenListSortingOperations.kt @@ -100,7 +100,7 @@ internal class TokenListSortingOperations( private fun CryptoCurrencyStatus.getTotalBalance(): BigDecimal { val yieldBalance = value.yieldBalance as? YieldBalance.Data val totalYieldBalance = yieldBalance?.getTotalWithRewardsStakingBalance().orZero() - val totalFiatYieldBalance = if (!BlockchainUtils.isIncludeStakingTotalBalance(currency.network.id.value)) { + val totalFiatYieldBalance = if (BlockchainUtils.isIncludeStakingTotalBalance(currency.network.id.value)) { totalYieldBalance.multiply(value.fiatRate.orZero()) } else { BigDecimal.ZERO