diff --git a/core/src/main/java/haveno/core/trade/Trade.java b/core/src/main/java/haveno/core/trade/Trade.java index a6c7d34b2d..ad29d838b5 100644 --- a/core/src/main/java/haveno/core/trade/Trade.java +++ b/core/src/main/java/haveno/core/trade/Trade.java @@ -39,7 +39,6 @@ import com.google.protobuf.ByteString; import com.google.protobuf.Message; import haveno.common.ThreadUtils; import haveno.common.UserThread; -import haveno.common.app.Capability; import haveno.common.crypto.Encryption; import haveno.common.crypto.PubKeyRing; import haveno.common.proto.ProtoUtil; @@ -2181,23 +2180,15 @@ public abstract class Trade implements Tradable, Model { } private void doPublishTradeStatistics() { - processModel.getP2PService().findPeersCapabilities(getTradePeer().getNodeAddress()) - .filter(capabilities -> capabilities.containsAll(Capability.TRADE_STATISTICS_3)) - .ifPresentOrElse(capabilities -> { - String referralId = processModel.getReferralIdService().getOptionalReferralId().orElse(null); - boolean isTorNetworkNode = getProcessModel().getP2PService().getNetworkNode() instanceof TorNetworkNode; - TradeStatistics3 tradeStatistics = TradeStatistics3.from(this, referralId, isTorNetworkNode); - if (tradeStatistics.isValid()) { - log.info("Publishing trade statistics"); - processModel.getP2PService().addPersistableNetworkPayload(tradeStatistics, true); - } else { - log.warn("Trade statistics are invalid. We do not publish. {}", tradeStatistics); - } - }, - () -> { - log.info("Our peer does not has updated yet, so they will publish the trade statistics. " + - "To avoid duplicates we do not publish from our side."); - }); + String referralId = processModel.getReferralIdService().getOptionalReferralId().orElse(null); + boolean isTorNetworkNode = getProcessModel().getP2PService().getNetworkNode() instanceof TorNetworkNode; + TradeStatistics3 tradeStatistics = TradeStatistics3.from(this, referralId, isTorNetworkNode); + if (tradeStatistics.isValid()) { + log.info("Publishing trade statistics for {} {}", getClass().getSimpleName(), getId()); + processModel.getP2PService().addPersistableNetworkPayload(tradeStatistics, true); + } else { + log.warn("Trade statistics are invalid for {} {}. We do not publish: {}", getClass().getSimpleName(), getId(), tradeStatistics); + } } diff --git a/p2p/src/main/java/haveno/network/p2p/P2PService.java b/p2p/src/main/java/haveno/network/p2p/P2PService.java index 8bdae835b8..a8028d0e2e 100644 --- a/p2p/src/main/java/haveno/network/p2p/P2PService.java +++ b/p2p/src/main/java/haveno/network/p2p/P2PService.java @@ -564,6 +564,7 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis return keyRing; } + // TODO: this is unreliable and unused, because peer sometimes reports no TRADE_STATISTICS_3 capability, causing valid trades to be unpublished public Optional findPeersCapabilities(NodeAddress peer) { return networkNode.getConfirmedConnections().stream() .filter(e -> e.getPeersNodeAddressOptional().isPresent())