mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-27 00:09:34 -05:00
seller publishes trade statistics without checking peer capabilities
This commit is contained in:
parent
37af7e5338
commit
ca125dbc48
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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<Capabilities> findPeersCapabilities(NodeAddress peer) {
|
||||
return networkNode.getConfirmedConnections().stream()
|
||||
.filter(e -> e.getPeersNodeAddressOptional().isPresent())
|
||||
|
Loading…
Reference in New Issue
Block a user