Skip to content

Commit

Permalink
Merge pull request #3958 from ripcurlx/revert-setting-deposittxid-null
Browse files Browse the repository at this point in the history
Revert setting of null to deposit tx id
  • Loading branch information
sqrrm authored Feb 10, 2020
2 parents ac7d636 + f516da6 commit 923487e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected void run() {
trade.getTradePrice(),
trade.getTradeAmount(),
trade.getDate(),
null,
trade.getDepositTxId(),
extraDataMap);
processModel.getP2PService().addPersistableNetworkPayload(tradeStatistics, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -81,6 +82,9 @@ public void onAllServicesInitialized() {
Set<TradeStatistics2> 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);
Expand Down Expand Up @@ -150,4 +154,29 @@ 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());
}
}
}

0 comments on commit 923487e

Please sign in to comment.