mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-23 03:59:36 +00:00
deduplicate additional trade statistics (#1326)
This commit is contained in:
parent
cda610fdfd
commit
a6c178c058
1 changed files with 4 additions and 8 deletions
|
@ -120,22 +120,18 @@ public class TradeStatisticsManager {
|
||||||
// collect duplicated trades
|
// collect duplicated trades
|
||||||
Set<TradeStatistics3> duplicates = new HashSet<TradeStatistics3>();
|
Set<TradeStatistics3> duplicates = new HashSet<TradeStatistics3>();
|
||||||
Set<TradeStatistics3> deduplicates = new HashSet<TradeStatistics3>();
|
Set<TradeStatistics3> deduplicates = new HashSet<TradeStatistics3>();
|
||||||
Set<TradeStatistics3> usedAsDuplicate = new HashSet<TradeStatistics3>();
|
|
||||||
for (TradeStatistics3 tradeStatistic : earlyTrades) {
|
for (TradeStatistics3 tradeStatistic : earlyTrades) {
|
||||||
TradeStatistics3 fuzzyDuplicate = findFuzzyDuplicate(tradeStatistic, deduplicates, usedAsDuplicate);
|
TradeStatistics3 fuzzyDuplicate = findFuzzyDuplicate(tradeStatistic, deduplicates);
|
||||||
if (fuzzyDuplicate == null) deduplicates.add(tradeStatistic);
|
if (fuzzyDuplicate == null) deduplicates.add(tradeStatistic);
|
||||||
else {
|
else duplicates.add(tradeStatistic);
|
||||||
duplicates.add(tradeStatistic);
|
|
||||||
usedAsDuplicate.add(fuzzyDuplicate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove duplicated trades
|
// remove duplicated trades
|
||||||
tradeStats.removeAll(duplicates);
|
tradeStats.removeAll(duplicates);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TradeStatistics3 findFuzzyDuplicate(TradeStatistics3 tradeStatistics, Set<TradeStatistics3> set, Set<TradeStatistics3> excluded) {
|
private TradeStatistics3 findFuzzyDuplicate(TradeStatistics3 tradeStatistics, Set<TradeStatistics3> set) {
|
||||||
return set.stream().filter(e -> !excluded.contains(e)).filter(e -> isFuzzyDuplicate(tradeStatistics, e)).findFirst().orElse(null);
|
return set.stream().filter(e -> isFuzzyDuplicate(tradeStatistics, e)).findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isFuzzyDuplicate(TradeStatistics3 tradeStatistics1, TradeStatistics3 tradeStatistics2) {
|
private boolean isFuzzyDuplicate(TradeStatistics3 tradeStatistics1, TradeStatistics3 tradeStatistics2) {
|
||||||
|
|
Loading…
Reference in a new issue