Updated on 2026-08-14

This commit is contained in:
Tangem 2023-10-12 16:01:51 +03:00
parent c795074253
commit e7da35375b

View file

@ -53,7 +53,7 @@ internal class DefaultNetworksRepository(
override suspend fun fetchNetworkPendingTransactions(userWalletId: UserWalletId, networks: Set<Network>) {
withContext(dispatchers.io) {
fetchNetworksPendingTransactionsIfCacheExpired(userWalletId, networks, false)
fetchNetworksPendingTransactions(userWalletId, networks)
}
}
@ -82,16 +82,12 @@ internal class DefaultNetworksRepository(
}
}
private suspend fun fetchNetworksPendingTransactionsIfCacheExpired(
userWalletId: UserWalletId,
networks: Set<Network>,
refresh: Boolean,
) {
private suspend fun fetchNetworksPendingTransactions(userWalletId: UserWalletId, networks: Set<Network>) {
coroutineScope {
networks
.map { network ->
async {
fetchNetworkPendingTransactionsIfCacheExpired(userWalletId, network, refresh)
fetchNetworkPendingTransactions(userWalletId, network)
}
}
.awaitAll()
@ -110,20 +106,6 @@ internal class DefaultNetworksRepository(
)
}
private suspend fun fetchNetworkPendingTransactionsIfCacheExpired(
userWalletId: UserWalletId,
network: Network,
refresh: Boolean,
) {
val key = getNetworksStatusesCacheKey(userWalletId, network)
cacheRegistry.invalidate(key)
cacheRegistry.invokeOnExpire(
key = key,
skipCache = refresh,
block = { fetchNetworkPendingTransactions(userWalletId, network) },
)
}
private suspend fun fetchNetworkStatus(userWalletId: UserWalletId, network: Network) {
val currencies = getCurrencies(userWalletId, network)