Skip to content

Commit 7956098

Browse files
refactor: use nowMillis ext for reset timestamp
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent c534c74 commit 7956098

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ suspend fun getData(): Result<Data> = withContext(Dispatchers.IO) {
178178
- ALWAYS check existing code patterns before implementing new features
179179
- USE existing extensions and utilities rather than creating new ones
180180
- ALWAYS use or create `Context` extension properties in `ext/Context.kt` instead of raw `context.getSystemService()` casts
181+
- NEVER use `System.currentTimeMillis()`, use time helpers from `ext/DateTime.kt` instead (e.g. `nowMillis()`, `Clock.nowMs()`) — they accept a `Clock` and are unit-testable
181182
- ALWAYS apply the YAGNI (You Ain't Gonna Need It) principle for new code
182183
- ALWAYS reuse existing constants
183184
- ALWAYS ensure a method exist before calling it

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import to.bitkit.di.BgDispatcher
6161
import to.bitkit.env.Defaults
6262
import to.bitkit.env.Env
6363
import to.bitkit.ext.getSatsPerVByteFor
64+
import to.bitkit.ext.nowMillis
6465
import to.bitkit.ext.nowTimestamp
6566
import to.bitkit.ext.toPeerDetailsList
6667
import to.bitkit.ext.totalNextOutboundHtlcLimitSats
@@ -99,6 +100,7 @@ import kotlin.time.Duration
99100
import kotlin.time.Duration.Companion.milliseconds
100101
import kotlin.time.Duration.Companion.minutes
101102
import kotlin.time.Duration.Companion.seconds
103+
import kotlin.time.ExperimentalTime
102104

103105
@Singleton
104106
@Suppress("LongParameterList", "TooManyFunctions", "LargeClass")
@@ -1629,6 +1631,7 @@ class LightningRepo @Inject constructor(
16291631
* Returns the device epoch seconds captured after the VSS deletes and before the node restart,
16301632
* so callers can require any scores sync timestamp to be strictly newer to prove a post-reset download.
16311633
*/
1634+
@OptIn(ExperimentalTime::class)
16321635
suspend fun resetPathfindingScores(walletIndex: Int = 0): Result<Long> = withContext(bgDispatcher) {
16331636
Logger.info("Resetting pathfinding scores", context = TAG)
16341637

@@ -1654,7 +1657,7 @@ class LightningRepo @Inject constructor(
16541657
return@withContext Result.failure(it)
16551658
}
16561659

1657-
val resetAtSecs = System.currentTimeMillis() / 1000
1660+
val resetAtSecs = nowMillis() / 1000
16581661

16591662
start(walletIndex = walletIndex, shouldRetry = false)
16601663
.map { resetAtSecs }

0 commit comments

Comments
 (0)