From a6c178c058ef0827a085476e2ef5a5a9c0c5f2c7 Mon Sep 17 00:00:00 2001 From: woodser Date: Sun, 13 Oct 2024 08:31:59 -0400 Subject: [PATCH] deduplicate additional trade statistics (#1326) --- .../trade/statistics/TradeStatisticsManager.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/haveno/core/trade/statistics/TradeStatisticsManager.java b/core/src/main/java/haveno/core/trade/statistics/TradeStatisticsManager.java index 449fca5d..b85e6932 100644 --- a/core/src/main/java/haveno/core/trade/statistics/TradeStatisticsManager.java +++ b/core/src/main/java/haveno/core/trade/statistics/TradeStatisticsManager.java @@ -120,22 +120,18 @@ public class TradeStatisticsManager { // collect duplicated trades Set duplicates = new HashSet(); Set deduplicates = new HashSet(); - Set usedAsDuplicate = new HashSet(); for (TradeStatistics3 tradeStatistic : earlyTrades) { - TradeStatistics3 fuzzyDuplicate = findFuzzyDuplicate(tradeStatistic, deduplicates, usedAsDuplicate); + TradeStatistics3 fuzzyDuplicate = findFuzzyDuplicate(tradeStatistic, deduplicates); if (fuzzyDuplicate == null) deduplicates.add(tradeStatistic); - else { - duplicates.add(tradeStatistic); - usedAsDuplicate.add(fuzzyDuplicate); - } + else duplicates.add(tradeStatistic); } // remove duplicated trades tradeStats.removeAll(duplicates); } - private TradeStatistics3 findFuzzyDuplicate(TradeStatistics3 tradeStatistics, Set set, Set excluded) { - return set.stream().filter(e -> !excluded.contains(e)).filter(e -> isFuzzyDuplicate(tradeStatistics, e)).findFirst().orElse(null); + private TradeStatistics3 findFuzzyDuplicate(TradeStatistics3 tradeStatistics, Set set) { + return set.stream().filter(e -> isFuzzyDuplicate(tradeStatistics, e)).findFirst().orElse(null); } private boolean isFuzzyDuplicate(TradeStatistics3 tradeStatistics1, TradeStatistics3 tradeStatistics2) {