Skip to content

Commit 6f1de1b

Browse files
committed
feat: Use 1 minute interval for coop close retries
1 parent 7a7702b commit 6f1de1b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

app/src/main/java/to/bitkit/viewmodels/TransferViewModel.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ import kotlin.math.max
3232
import kotlin.math.min
3333
import kotlin.math.roundToLong
3434

35-
const val RETRY_INTERVAL = 5 * 60 * 1000L // 5 minutes in ms
36-
const val GIVE_UP = 30 * 60 * 1000L // 30 minutes in ms
35+
const val RETRY_INTERVAL_MS = 1 * 60 * 1000L // 1 minutes in ms
36+
const val GIVE_UP_MS = 30 * 60 * 1000L // 30 minutes in ms
3737

3838
@HiltViewModel
3939
class TransferViewModel @Inject constructor(
@@ -300,12 +300,12 @@ class TransferViewModel @Inject constructor(
300300
private var coopCloseRetryJob: Job? = null
301301

302302
/** Retry to coop close the channel(s) for 30 min */
303-
fun startCoopCloseRetries(channels: List<ChannelDetails>, startTime: Long) {
303+
fun startCoopCloseRetries(channels: List<ChannelDetails>, startTimeMs: Long) {
304304
channelsToClose = channels
305305
coopCloseRetryJob?.cancel()
306306

307307
coopCloseRetryJob = viewModelScope.launch {
308-
val giveUpTime = startTime + GIVE_UP
308+
val giveUpTime = startTimeMs + GIVE_UP_MS
309309

310310
while (isActive && System.currentTimeMillis() < giveUpTime) {
311311
Logger.info("Trying coop close...")
@@ -320,7 +320,7 @@ class TransferViewModel @Inject constructor(
320320
Logger.info("Coop close failed: ${channelsFailedToCoopClose.map { it.channelId }}")
321321
}
322322

323-
delay(RETRY_INTERVAL)
323+
delay(RETRY_INTERVAL_MS)
324324
}
325325

326326
Logger.info("Giving up on coop close.")

0 commit comments

Comments
 (0)