Skip to content

Commit 0c33ee0

Browse files
fix: harden resetPathfindingScores error path
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent c15e582 commit 0c33ee0

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

app/src/main/java/to/bitkit/repositories/LightningRepo.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1635,12 +1635,18 @@ class LightningRepo @Inject constructor(
16351635
}
16361636

16371637
runCatching {
1638+
val lifecycleState = _lightningState.value.nodeLifecycleState
1639+
check(lifecycleState == NodeLifecycleState.Stopped) {
1640+
"Node lifecycle changed to '$lifecycleState' during pathfinding scores reset"
1641+
}
16381642
vssBackupClientLdk.setup(walletIndex).getOrThrow()
16391643
vssBackupClientLdk.deleteObject(VSS_KEY_SCORER).getOrThrow()
16401644
vssBackupClientLdk.deleteObject(VSS_KEY_EXTERNAL_SCORES_CACHE).getOrThrow()
16411645
}.onFailure {
16421646
Logger.error("Failed to delete pathfinding scores from VSS", it, context = TAG)
1643-
start(walletIndex = walletIndex, shouldRetry = false)
1647+
start(walletIndex = walletIndex, shouldRetry = false).onFailure { startError ->
1648+
Logger.error("Failed to restart node after pathfinding scores reset failure", startError, context = TAG)
1649+
}
16441650
return@withContext Result.failure(it)
16451651
}
16461652

0 commit comments

Comments
 (0)