Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions app/src/main/java/to/bitkit/repositories/LightningRepo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,12 @@ class LightningRepo @Inject constructor(
connectToTrustedPeers().onFailure {
Logger.error("Failed to connect to trusted peers", it, context = TAG)
}
sync().getOrThrow().also {
Comment thread
ovitrif marked this conversation as resolved.
scope.launch { registerForNotifications() }

sync().onFailure { e ->
Logger.warn("Initial sync failed, event-driven sync will retry", e, context = TAG)
}
scope.launch { registerForNotifications() }
Unit
Comment thread
jvsena42 marked this conversation as resolved.
Comment thread
ovitrif marked this conversation as resolved.
}.onFailure { e ->
if (shouldRetry) {
val retryDelay = 2.seconds
Expand All @@ -271,6 +274,7 @@ class LightningRepo @Inject constructor(
_lightningState.update {
it.copy(nodeLifecycleState = NodeLifecycleState.ErrorStarting(e))
}
return@withContext Result.failure(e)
}
}
}
Expand Down Expand Up @@ -321,7 +325,11 @@ class LightningRepo @Inject constructor(
do {
syncPending.set(false)
_lightningState.update { it.copy(isSyncingWallet = true) }
lightningService.sync()
runCatching {
lightningService.sync()
}.onFailure {
return@executeWhenNodeRunning Result.failure(it)
}
Comment thread
ovitrif marked this conversation as resolved.
Outdated
Comment thread
jvsena42 marked this conversation as resolved.
Outdated
refreshChannelCache()
syncState()
if (syncPending.get()) delay(MS_SYNC_LOOP_DEBOUNCE)
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/java/to/bitkit/viewmodels/WalletViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,15 @@ class WalletViewModel @Inject constructor(
walletRepo.syncNodeAndWallet()
.onFailure {
Logger.error("Failed to refresh state: ${it.message}", it)
if (it is CancellationException || it.isTxSyncTimeout()) return@onFailure
if (it is CancellationException) return@onFailure
if (it.isTxSyncTimeout()) {
ToastEventBus.send(
type = Toast.ToastType.ERROR,
title = context.getString(R.string.wallet__ldk_sync_error_title),
description = context.getString(R.string.wallet__ldk_sync_error_body),
)
return@onFailure
}
ToastEventBus.send(it)
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,7 @@
<string name="wallet__filter_title">Select Range</string>
<string name="wallet__instant_payment_received">Received Instant Bitcoin</string>
<string name="wallet__ldk_start_error_title">Lightning Startup Error</string>
<string name="wallet__ldk_sync_error_body">Unable to sync with the network. Please try again later.</string>
<string name="wallet__ldk_sync_error_title">Lightning Sync Error</string>
<string name="wallet__lnurl_p_max">Maximum amount</string>
<string name="wallet__lnurl_p_title">Pay Bitcoin</string>
Expand Down
Loading