Updated on 2026-08-14

This commit is contained in:
Tangem 2026-03-13 11:01:35 +04:00
parent 4f3ff79ac9
commit 158fd355de
9 changed files with 40 additions and 200 deletions

View file

@ -35,6 +35,10 @@ class CryptoCurrencyBalanceFetcher(
private val mutex = Mutex()
operator fun invoke(userWalletId: UserWalletId, currency: CryptoCurrency) {
invoke(userWalletId = userWalletId, currencies = listOf(currency))
}
operator fun invoke(userWalletId: UserWalletId, currencies: List<CryptoCurrency>) {
if (currencies.isEmpty()) return
@ -45,6 +49,18 @@ class CryptoCurrencyBalanceFetcher(
}
}
suspend fun invokeAndAwait(userWalletId: UserWalletId, currency: CryptoCurrency) {
invokeAndAwait(userWalletId = userWalletId, currencies = listOf(currency))
}
suspend fun invokeAndAwait(userWalletId: UserWalletId, currencies: List<CryptoCurrency>) {
if (currencies.isEmpty()) return
mutex.withLock {
refreshBalances(userWalletId, currencies)
}
}
private suspend fun refreshBalances(userWalletId: UserWalletId, currencies: List<CryptoCurrency>) {
coroutineScope {
val results = listOf(