mirror of
https://github.com/retoaccess1/haveno-reto.git
synced 2024-11-10 05:03:35 +01:00
seller publishes trade statistic on deposit response
This commit is contained in:
parent
a2c2f670da
commit
66d3a23ec2
2
Makefile
2
Makefile
@ -145,7 +145,7 @@ arbitrator-desktop-local:
|
||||
--apiPassword=apitest \
|
||||
--apiPort=9998
|
||||
|
||||
arbitrator-desktop2-local:
|
||||
arbitrator2-desktop-local:
|
||||
# Arbitrator needs to be registered before making trades
|
||||
./haveno-desktop$(APP_EXT) \
|
||||
--baseCurrencyNetwork=XMR_LOCAL \
|
||||
|
@ -1071,7 +1071,8 @@ public abstract class Trade implements Tradable, Model {
|
||||
if (depositId == null) return null;
|
||||
try {
|
||||
if (trader.getDepositTx() == null || !trader.getDepositTx().isConfirmed()) {
|
||||
trader.setDepositTx(getDepositTxFromWalletOrDaemon(depositId));
|
||||
MoneroTx depositTx = getDepositTxFromWalletOrDaemon(depositId);
|
||||
if (depositTx != null) trader.setDepositTx(depositTx);
|
||||
}
|
||||
return trader.getDepositTx();
|
||||
} catch (MoneroError e) {
|
||||
@ -1801,8 +1802,8 @@ public abstract class Trade implements Tradable, Model {
|
||||
if (tx.getHash().equals(processModel.getMaker().getDepositTxHash())) makerDepositTx = tx;
|
||||
if (tx.getHash().equals(processModel.getTaker().getDepositTxHash())) takerDepositTx = tx;
|
||||
}
|
||||
getMaker().setDepositTx(makerDepositTx);
|
||||
getTaker().setDepositTx(takerDepositTx);
|
||||
if (makerDepositTx != null) getMaker().setDepositTx(makerDepositTx);
|
||||
if (takerDepositTx != null) getTaker().setDepositTx(takerDepositTx);
|
||||
|
||||
// skip if deposit txs not seen
|
||||
if (makerDepositTx == null || takerDepositTx == null) return;
|
||||
|
@ -52,6 +52,7 @@ import haveno.core.trade.protocol.tasks.ProcessPaymentSentMessage;
|
||||
import haveno.core.trade.protocol.tasks.ProcessSignContractRequest;
|
||||
import haveno.core.trade.protocol.tasks.ProcessSignContractResponse;
|
||||
import haveno.core.trade.protocol.tasks.RemoveOffer;
|
||||
import haveno.core.trade.protocol.tasks.SellerPublishTradeStatistics;
|
||||
import haveno.core.trade.protocol.tasks.MaybeResendDisputeClosedMessageWithPayout;
|
||||
import haveno.core.trade.protocol.tasks.TradeTask;
|
||||
import haveno.core.trade.protocol.tasks.VerifyPeersAccountAgeWitness;
|
||||
@ -418,11 +419,11 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
||||
processModel.setTradeMessage(response);
|
||||
expect(anyState(Trade.State.SENT_PUBLISH_DEPOSIT_TX_REQUEST, Trade.State.SAW_ARRIVED_PUBLISH_DEPOSIT_TX_REQUEST, Trade.State.ARBITRATOR_PUBLISHED_DEPOSIT_TXS, Trade.State.DEPOSIT_TXS_SEEN_IN_NETWORK)
|
||||
.with(response)
|
||||
.from(sender)) // TODO (woodser): ensure this asserts sender == response.getSenderNodeAddress()
|
||||
.from(sender))
|
||||
.setup(tasks(
|
||||
// TODO (woodser): validate request
|
||||
ProcessDepositResponse.class,
|
||||
RemoveOffer.class)
|
||||
RemoveOffer.class,
|
||||
SellerPublishTradeStatistics.class)
|
||||
.using(new TradeTaskRunner(trade,
|
||||
() -> {
|
||||
stopTimeout();
|
||||
|
@ -17,10 +17,16 @@
|
||||
|
||||
package haveno.core.trade.protocol.tasks;
|
||||
|
||||
import haveno.common.app.Capability;
|
||||
import haveno.common.taskrunner.TaskRunner;
|
||||
import haveno.core.trade.SellerTrade;
|
||||
import haveno.core.trade.Trade;
|
||||
import haveno.core.trade.statistics.TradeStatistics3;
|
||||
import haveno.network.p2p.network.TorNetworkNode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Slf4j
|
||||
public class SellerPublishTradeStatistics extends TradeTask {
|
||||
public SellerPublishTradeStatistics(TaskRunner<Trade> taskHandler, Trade trade) {
|
||||
@ -29,37 +35,41 @@ public class SellerPublishTradeStatistics extends TradeTask {
|
||||
|
||||
@Override
|
||||
protected void run() {
|
||||
throw new RuntimeException("SellerPublishesTradeStatistics needs updated for XMR");
|
||||
// try {
|
||||
// runInterceptHook();
|
||||
//
|
||||
// checkNotNull(trade.getDepositTx());
|
||||
//
|
||||
// processModel.getP2PService().findPeersCapabilities(trade.getTradePeer().getNodeAddress())
|
||||
// .filter(capabilities -> capabilities.containsAll(Capability.TRADE_STATISTICS_3))
|
||||
// .ifPresentOrElse(capabilities -> {
|
||||
// // Our peer has updated, so as we are the seller we will publish the trade statistics.
|
||||
// // The peer as buyer does not publish anymore with v.1.4.0 (where Capability.TRADE_STATISTICS_3 was added)
|
||||
//
|
||||
// String referralId = processModel.getReferralIdService().getOptionalReferralId().orElse(null);
|
||||
// boolean isTorNetworkNode = model.getProcessModel().getP2PService().getNetworkNode() instanceof TorNetworkNode;
|
||||
// TradeStatistics3 tradeStatistics = TradeStatistics3.from(trade, 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);
|
||||
// }
|
||||
//
|
||||
// complete();
|
||||
// },
|
||||
// () -> {
|
||||
// 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.");
|
||||
// complete();
|
||||
// });
|
||||
// } catch (Throwable t) {
|
||||
// failed(t);
|
||||
// }
|
||||
try {
|
||||
runInterceptHook();
|
||||
|
||||
// skip if not seller
|
||||
if (!(trade instanceof SellerTrade)) {
|
||||
complete();
|
||||
return;
|
||||
}
|
||||
|
||||
checkNotNull(trade.getSeller().getDepositTx());
|
||||
processModel.getP2PService().findPeersCapabilities(trade.getTradePeer().getNodeAddress())
|
||||
.filter(capabilities -> capabilities.containsAll(Capability.TRADE_STATISTICS_3))
|
||||
.ifPresentOrElse(capabilities -> {
|
||||
// Our peer has updated, so as we are the seller we will publish the trade statistics.
|
||||
// The peer as buyer does not publish anymore with v.1.4.0 (where Capability.TRADE_STATISTICS_3 was added)
|
||||
|
||||
String referralId = processModel.getReferralIdService().getOptionalReferralId().orElse(null);
|
||||
boolean isTorNetworkNode = model.getProcessModel().getP2PService().getNetworkNode() instanceof TorNetworkNode;
|
||||
TradeStatistics3 tradeStatistics = TradeStatistics3.from(trade, 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);
|
||||
}
|
||||
|
||||
complete();
|
||||
},
|
||||
() -> {
|
||||
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.");
|
||||
complete();
|
||||
});
|
||||
} catch (Throwable t) {
|
||||
failed(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user