Skip to content

Commit 73e1da0

Browse files
committed
chore: review
1 parent b2690b9 commit 73e1da0

2 files changed

Lines changed: 8 additions & 12 deletions

File tree

app/src/main/java/to/bitkit/services/LightningService.kt

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -195,22 +195,17 @@ class LightningService @Inject constructor(
195195
}
196196
}
197197

198-
buildNode().recoverCatching {
199-
if (it !is BuildException.DangerousValue) throw it
200-
// Handle `DangerousValue` with recovery flow
198+
buildNode().recoverCatching { error ->
199+
if (error !is BuildException.DangerousValue) throw error
201200
Logger.warn(
202-
"Build failed with DangerousValue. Retrying with `accept_stale_channel_monitors` for recovery.",
203-
it,
201+
"Retrying build failed with 'DangerousValue' using 'setAcceptStaleChannelMonitors' for recovery.",
202+
error,
204203
context = TAG,
205204
)
206205
builder.setAcceptStaleChannelMonitors(true)
207206
buildNode()
208-
.onFailure { recoveryError ->
209-
Logger.error(
210-
"Error in recovery attempt with `accept_stale_channel_monitors`.",
211-
recoveryError,
212-
context = TAG,
213-
)
207+
.onFailure {
208+
Logger.error("Failed recovery retry using 'setAcceptStaleChannelMonitors'.", it, context = TAG)
214209
}
215210
.getOrThrow()
216211
}.getOrThrow()
@@ -249,7 +244,7 @@ class LightningService @Inject constructor(
249244
lightningWalletSyncIntervalSecs = Env.walletSyncIntervalSecs,
250245
feeRateCacheUpdateIntervalSecs = Env.walletSyncIntervalSecs,
251246
),
252-
connectionTimeoutSecs = Env.walletSyncTimeoutSecs, // 10s
247+
connectionTimeoutSecs = Env.walletSyncTimeoutSecs,
253248
),
254249
)
255250
}

app/src/main/java/to/bitkit/utils/Errors.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class LdkError(private val inner: LdkException) : AppError("Unknown LDK error.")
4949
is BuildException.InvalidAnnouncementAddresses -> "Invalid announcement addresses"
5050
is BuildException.InvalidNodeAlias -> "Invalid node alias"
5151
is BuildException.NetworkMismatch -> "Network mismatch"
52+
is BuildException.DangerousValue -> "Dangerous value"
5253
else -> exception.message
5354
}?.let { "LDK Build error: $it" }
5455
}

0 commit comments

Comments
 (0)