mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-10-06 03:38:23 +00:00
fix(cashu): drop the JVM-only HashMap.putIfAbsent from commonMain
CashuMintOperations.checkProofStates used java.util.HashMap.putIfAbsent, which the commonMain metadata compile rejects. The map is local and single-threaded, so an explicit contains-then-set keeps the same first-secret-wins behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S7FuNBSKiyVecARSoE4B9P
This commit is contained in:
+5
-2
@@ -687,10 +687,13 @@ class CashuMintOperations(
|
||||
val ys = ArrayList<String>(proofs.size)
|
||||
proofs.forEach { proof ->
|
||||
val y = Bdhke.hashToCurveCompressed(proof.secret.encodeToByteArray()).toHexKey()
|
||||
// putIfAbsent: two proofs can legitimately carry the same secret
|
||||
// First one wins: two proofs can legitimately carry the same secret
|
||||
// (a duplicated kind:7375 the dedup pass hasn't retired yet), and
|
||||
// they map to the same state anyway.
|
||||
if (secretByY.putIfAbsent(y, proof.secret) == null) ys.add(y)
|
||||
if (y !in secretByY) {
|
||||
secretByY[y] = proof.secret
|
||||
ys.add(y)
|
||||
}
|
||||
}
|
||||
|
||||
val out = HashMap<String, ProofState>(secretByY.size)
|
||||
|
||||
Reference in New Issue
Block a user