mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-07-22 12:39:30 +00:00
The `regenerate: bool` param was control coupling: every caller passing `regenerate = true` was a retry path that had already established `rln.isSome()` (it just called `invalidateMerkleProofCache` on the group manager) and wanted an unconditional fresh proof, not a "check and maybe generate". Extract that into `attachRLNProof(r: Rln, message)`, which always draws a fresh nonce and rebuilds the proof, replacing any existing one. `checkAndGenerateRLNProof(rln: Option[Rln], message)` keeps only its "check" behaviour — short-circuit on an existing proof, pass through when RLN is not configured — and delegates to `attachRLNProof`. Taking a concrete `Rln` deletes the previously unreachable `regenerate = true` + `rln.isNone()` branch (which would have republished the stale rejected proof) at the type level, and removes the duplicated nonce-draw/generateProof/encode body that checkAndGenerateRLNProof carried alongside generateRLNProof. The two lightpush retry sites and the invalidate+regenerate test now call attachRLNProof directly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>