From 834e00fbb98c589cb064f70a7396c02413d6a559 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Mon, 10 Feb 2020 13:15:12 +0100 Subject: [PATCH 1/3] Revert setting of deposit tx id to null --- .../bisq/core/trade/protocol/tasks/PublishTradeStatistics.java | 2 +- .../main/java/bisq/core/trade/statistics/TradeStatistics2.java | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/PublishTradeStatistics.java b/core/src/main/java/bisq/core/trade/protocol/tasks/PublishTradeStatistics.java index 1cb10f16e96..421b69e1857 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/PublishTradeStatistics.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/PublishTradeStatistics.java @@ -70,7 +70,7 @@ protected void run() { trade.getTradePrice(), trade.getTradeAmount(), trade.getDate(), - null, + trade.getDepositTxId(), extraDataMap); processModel.getP2PService().addPersistableNetworkPayload(tradeStatistics, true); } diff --git a/core/src/main/java/bisq/core/trade/statistics/TradeStatistics2.java b/core/src/main/java/bisq/core/trade/statistics/TradeStatistics2.java index 1e4c87abe69..1983ec52be8 100644 --- a/core/src/main/java/bisq/core/trade/statistics/TradeStatistics2.java +++ b/core/src/main/java/bisq/core/trade/statistics/TradeStatistics2.java @@ -47,7 +47,6 @@ import com.google.common.base.Charsets; import java.util.Date; -import java.util.GregorianCalendar; import java.util.Map; import java.util.Optional; @@ -71,8 +70,6 @@ public final class TradeStatistics2 implements ProcessOncePersistableNetworkPayl public static final String MEDIATOR_ADDRESS = "medAddr"; public static final String REFUND_AGENT_ADDRESS = "refAddr"; - public static final Date CUT_OFF_DATE_FOR_DEPOSIT_TX_ID = Utilities.getUTCDate(2019, GregorianCalendar.FEBRUARY, 13); - private final OfferPayload.Direction direction; private final String baseCurrency; private final String counterCurrency; From 447c7e8fa4df3f92f1eed47cbff943868cfee849 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Mon, 10 Feb 2020 13:15:56 +0100 Subject: [PATCH 2/3] Remove duplicates when delivered from storage --- .../statistics/TradeStatisticsManager.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/core/src/main/java/bisq/core/trade/statistics/TradeStatisticsManager.java b/core/src/main/java/bisq/core/trade/statistics/TradeStatisticsManager.java index ee0fbc03d4e..d8ef03c1533 100644 --- a/core/src/main/java/bisq/core/trade/statistics/TradeStatisticsManager.java +++ b/core/src/main/java/bisq/core/trade/statistics/TradeStatisticsManager.java @@ -40,6 +40,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -81,6 +82,9 @@ public void onAllServicesInitialized() { Set collect = tradeStatistics2StorageService.getMap().values().stream() .filter(e -> e instanceof TradeStatistics2) .map(e -> (TradeStatistics2) e) + .map(WrapperTradeStatistics2::new) + .distinct() + .map(WrapperTradeStatistics2::unwrap) .filter(TradeStatistics2::isValid) .collect(Collectors.toSet()); observableTradeStatisticsSet.addAll(collect); @@ -150,4 +154,30 @@ private void dump() { jsonFileManager.writeToDisc(Utilities.objectToJson(array), "trade_statistics"); } } + + static class WrapperTradeStatistics2 { + private TradeStatistics2 tradeStatistics; + + public WrapperTradeStatistics2(TradeStatistics2 tradeStatistics) { + + this.tradeStatistics = tradeStatistics; + } + + public TradeStatistics2 unwrap() { + return this.tradeStatistics; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + var wrapper = (WrapperTradeStatistics2) obj; + return Objects.equals(tradeStatistics.getOfferId(), wrapper.tradeStatistics.getOfferId()); + } + + @Override + public int hashCode() { + return Objects.hash(tradeStatistics.getOfferId()); + } + } } From f516da68107900acd90119a3d79ddf88cc037202 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Mon, 10 Feb 2020 13:49:54 +0100 Subject: [PATCH 3/3] Remove empty line Co-Authored-By: sqrrm --- .../java/bisq/core/trade/statistics/TradeStatisticsManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/java/bisq/core/trade/statistics/TradeStatisticsManager.java b/core/src/main/java/bisq/core/trade/statistics/TradeStatisticsManager.java index d8ef03c1533..4d90fc143c9 100644 --- a/core/src/main/java/bisq/core/trade/statistics/TradeStatisticsManager.java +++ b/core/src/main/java/bisq/core/trade/statistics/TradeStatisticsManager.java @@ -159,7 +159,6 @@ static class WrapperTradeStatistics2 { private TradeStatistics2 tradeStatistics; public WrapperTradeStatistics2(TradeStatistics2 tradeStatistics) { - this.tradeStatistics = tradeStatistics; }