File tree Expand file tree Collapse file tree
app/src/main/java/to/bitkit/repositories Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -152,19 +152,22 @@ class BlocktankRepo @Inject constructor(
152152
153153 private suspend fun refreshCjitEntries (): List <IcJitEntry > {
154154 repeat(CJIT_REFRESH_ATTEMPTS ) { attempt ->
155- runCatching {
155+ val entries = runCatching {
156156 withTimeout(CJIT_REFRESH_TIMEOUT ) {
157157 coreService.blocktank.cjitEntries(refresh = true )
158158 }
159- }.onSuccess { entries ->
159+ }.mapCatching { entries ->
160160 _blocktankState .update { it.copy(cjitEntries = entries.toImmutableList()) }
161- return entries
162- }.onFailure {
161+ entries
162+ }.getOrElse {
163163 if (it is CancellationException && it !is TimeoutCancellationException ) throw it
164164 if (attempt == CJIT_REFRESH_ATTEMPTS - 1 ) {
165165 Logger .warn(" Failed to refresh CJIT entries; using cached state" , it, context = TAG )
166166 }
167+ null
167168 }
169+
170+ entries?.let { return it }
168171 delay(CJIT_REFRESH_RETRY_DELAY )
169172 }
170173 return _blocktankState .value.cjitEntries
You can’t perform that action at this time.
0 commit comments