From 639f24e9d0c4665f5c598a718673d0d0fff48e49 Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Tue, 13 Aug 2024 16:46:34 -0700 Subject: [PATCH] fix: align sorting of inputs by rounds to Dash Core (C++) --- .../java/org/bitcoinj/coinjoin/CoinJoinClientSession.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/org/bitcoinj/coinjoin/CoinJoinClientSession.java b/core/src/main/java/org/bitcoinj/coinjoin/CoinJoinClientSession.java index 878522365..81725df4c 100644 --- a/core/src/main/java/org/bitcoinj/coinjoin/CoinJoinClientSession.java +++ b/core/src/main/java/org/bitcoinj/coinjoin/CoinJoinClientSession.java @@ -1500,11 +1500,9 @@ public boolean submitDenominate() { } // more inputs first, for equal input count prefer the one with fewer rounds - Collections.sort(vecInputsByRounds, new Comparator>() { - @Override - public int compare(Pair a, Pair b) { - return (a.getSecond() > b.getSecond()) ? a.getSecond() - b.getSecond() : a.getFirst() - b.getFirst(); - } + vecInputsByRounds.sort((a, b) -> { + int inputCompare = Integer.compare(b.getSecond(), a.getSecond()); + return inputCompare != 0 ? inputCompare : Integer.compare(a.getFirst(), b.getFirst()); }); log.info("coinjoin: vecInputsByRounds(size={}) for denom {}", vecInputsByRounds.size(), sessionDenom);