diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PoWPublishQueue.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PoWPublishQueue.kt index 49f42f3e58..e0e7f0f3ef 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PoWPublishQueue.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PoWPublishQueue.kt @@ -214,15 +214,10 @@ class PoWPublishQueue( difficulty = difficulty, persistAs = persistAs, owner = pubKey, - mine = { isActive -> - val toMine = - if (clock != null) { - EventTemplate(clock(), template.kind, template.tags, template.content) - } else { - template - } - PoWMiner.mine(toMine, pubKey, difficulty, minerThreads, isActive, clock) - }, + // the miner stamps the first pass from the same clock, so the job + // picks up "now" whether it waited in the queue or was restored + // from disk — no need to re-wrap the template here. + mine = { isActive -> PoWMiner.mine(template, pubKey, difficulty, minerThreads, isActive, clock) }, publish = onMined, // send-now fallback: the same template, minus the nonce the miner would // have added. created_at follows the mined path — refreshed to "now" for diff --git a/quartz/plans/2026-08-13-gpu-pow-mining.md b/quartz/plans/2026-08-13-gpu-pow-mining.md index fd296e1eb0..0f3de9a517 100644 --- a/quartz/plans/2026-08-13-gpu-pow-mining.md +++ b/quartz/plans/2026-08-13-gpu-pow-mining.md @@ -197,10 +197,12 @@ is no longer blocking any UI could use more. NIP-90 kinds 5970/6970 — hand the template to a DVM with real hardware. That beats every on-device option and is already specced. -## Advancing `created_at` while mining +## Advancing `created_at` while mining — SHIPPED Not a speedup — a correctness fix that this analysis is a prerequisite for, because -it interacts with the midstate. +it interacts with the midstate. Implemented as described below; `PoWMiner.run/mine` +take an optional `refreshCreatedAt: (() -> Long)?`, covered by +`quartz/…/PoWMinerCreatedAtTest.kt`. NIP-13: *"It is recommended to update the `created_at` as well during this process."* We do half of it. `PoWPublishQueue.enqueue(refreshCreatedAtOnStart = …)` and the @@ -224,6 +226,11 @@ frozen behaviour. The consumers are already correct — `PoWNostrSigner` forward `mined.createdAt` to `signer.sign(…)`, and the queue publishes the mined template — so this is contained inside `PoWMiner` plus one flag at the call sites. +The new parameter goes **last**, after `isActive`, so the trailing-lambda call sites +keep binding their lambda to `isActive`. Kotlin would otherwise silently retarget them +at `refreshCreatedAt`; the `Boolean`/`Long` mismatch makes that a compile error rather +than a bug, but those sites were rewritten to a named `isActive = { … }` anyway. + **"When we can" is already modelled.** Reuse `refreshCreatedAtOnStart`'s predicate rather than inventing a second one; its comment already states the exclusion — *"Must stay false for scheduled posts, whose future created_at is intentional."*