mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-02 11:46:11 -04:00
remove unused fields from TradePeer and Contract
fix concurrent modification exception applying prices to trade stats standardize offer fee tx ids (unused)
This commit is contained in:
parent
a16b03bb5c
commit
47f3d98597
28 changed files with 60 additions and 108 deletions
|
@ -41,7 +41,6 @@ public class ContractInfo implements Payload {
|
|||
private final PaymentAccountPayload takerPaymentAccountPayload;
|
||||
private final String makerPayoutAddressString;
|
||||
private final String takerPayoutAddressString;
|
||||
private final long lockTime;
|
||||
|
||||
public ContractInfo(String buyerNodeAddress,
|
||||
String sellerNodeAddress,
|
||||
|
@ -52,8 +51,7 @@ public class ContractInfo implements Payload {
|
|||
PaymentAccountPayload makerPaymentAccountPayload,
|
||||
PaymentAccountPayload takerPaymentAccountPayload,
|
||||
String makerPayoutAddressString,
|
||||
String takerPayoutAddressString,
|
||||
long lockTime) {
|
||||
String takerPayoutAddressString) {
|
||||
this.buyerNodeAddress = buyerNodeAddress;
|
||||
this.sellerNodeAddress = sellerNodeAddress;
|
||||
this.arbitratorNodeAddress = arbitratorNodeAddress;
|
||||
|
@ -64,7 +62,6 @@ public class ContractInfo implements Payload {
|
|||
this.takerPaymentAccountPayload = takerPaymentAccountPayload;
|
||||
this.makerPayoutAddressString = makerPayoutAddressString;
|
||||
this.takerPayoutAddressString = takerPayoutAddressString;
|
||||
this.lockTime = lockTime;
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,8 +76,7 @@ public class ContractInfo implements Payload {
|
|||
null,
|
||||
null,
|
||||
"",
|
||||
"",
|
||||
0);
|
||||
"");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PROTO BUFFER
|
||||
|
@ -97,8 +93,7 @@ public class ContractInfo implements Payload {
|
|||
proto.getMakerPaymentAccountPayload() == null ? null : PaymentAccountPayload.fromProto(proto.getMakerPaymentAccountPayload(), coreProtoResolver),
|
||||
proto.getTakerPaymentAccountPayload() == null ? null : PaymentAccountPayload.fromProto(proto.getTakerPaymentAccountPayload(), coreProtoResolver),
|
||||
proto.getMakerPayoutAddressString(),
|
||||
proto.getTakerPayoutAddressString(),
|
||||
proto.getLockTime());
|
||||
proto.getTakerPayoutAddressString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -111,8 +106,7 @@ public class ContractInfo implements Payload {
|
|||
.setMakerAccountId(makerAccountId)
|
||||
.setTakerAccountId(takerAccountId)
|
||||
.setMakerPayoutAddressString(makerPayoutAddressString)
|
||||
.setTakerPayoutAddressString(takerPayoutAddressString)
|
||||
.setLockTime(lockTime);
|
||||
.setTakerPayoutAddressString(takerPayoutAddressString);
|
||||
if (makerPaymentAccountPayload != null) builder.setMakerPaymentAccountPayload((protobuf.PaymentAccountPayload) makerPaymentAccountPayload.toProtoMessage());
|
||||
if (takerPaymentAccountPayload != null) builder.setTakerPaymentAccountPayload((protobuf.PaymentAccountPayload) takerPaymentAccountPayload.toProtoMessage());
|
||||
return builder.build();
|
||||
|
|
|
@ -54,7 +54,7 @@ public class OfferInfo implements Payload {
|
|||
private final String minVolume;
|
||||
private final long makerFee;
|
||||
@Nullable
|
||||
private final String offerFeePaymentTxId;
|
||||
private final String offerFeeTxId;
|
||||
private final long buyerSecurityDeposit;
|
||||
private final long sellerSecurityDeposit;
|
||||
private final String triggerPrice;
|
||||
|
@ -87,7 +87,7 @@ public class OfferInfo implements Payload {
|
|||
this.volume = builder.getVolume();
|
||||
this.minVolume = builder.getMinVolume();
|
||||
this.makerFee = builder.getMakerFee();
|
||||
this.offerFeePaymentTxId = builder.getOfferFeePaymentTxId();
|
||||
this.offerFeeTxId = builder.getOfferFeeTxId();
|
||||
this.buyerSecurityDeposit = builder.getBuyerSecurityDeposit();
|
||||
this.sellerSecurityDeposit = builder.getSellerSecurityDeposit();
|
||||
this.triggerPrice = builder.getTriggerPrice();
|
||||
|
@ -153,7 +153,7 @@ public class OfferInfo implements Payload {
|
|||
.withVolume(roundedVolume)
|
||||
.withMinVolume(roundedMinVolume)
|
||||
.withMakerFee(offer.getMakerFee().longValueExact())
|
||||
.withOfferFeePaymentTxId(offer.getOfferFeePaymentTxId())
|
||||
.withOfferFeeTxId(offer.getOfferFeeTxId())
|
||||
.withBuyerSecurityDeposit(offer.getBuyerSecurityDeposit().longValueExact())
|
||||
.withSellerSecurityDeposit(offer.getSellerSecurityDeposit().longValueExact())
|
||||
.withPaymentAccountId(offer.getMakerPaymentAccountId())
|
||||
|
@ -204,7 +204,7 @@ public class OfferInfo implements Payload {
|
|||
.setVersionNr(versionNumber)
|
||||
.setProtocolVersion(protocolVersion);
|
||||
Optional.ofNullable(arbitratorSigner).ifPresent(builder::setArbitratorSigner);
|
||||
Optional.ofNullable(offerFeePaymentTxId).ifPresent(builder::setOfferFeePaymentTxId);
|
||||
Optional.ofNullable(offerFeeTxId).ifPresent(builder::setOfferFeeTxId);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ public class OfferInfo implements Payload {
|
|||
.withVolume(proto.getVolume())
|
||||
.withMinVolume(proto.getMinVolume())
|
||||
.withMakerFee(proto.getMakerFee())
|
||||
.withOfferFeePaymentTxId(ProtoUtil.stringOrNullFromProto(proto.getOfferFeePaymentTxId()))
|
||||
.withOfferFeeTxId(ProtoUtil.stringOrNullFromProto(proto.getOfferFeeTxId()))
|
||||
.withBuyerSecurityDeposit(proto.getBuyerSecurityDeposit())
|
||||
.withSellerSecurityDeposit(proto.getSellerSecurityDeposit())
|
||||
.withTriggerPrice(proto.getTriggerPrice())
|
||||
|
|
|
@ -143,8 +143,7 @@ public class TradeInfo implements Payload {
|
|||
trade.getMaker().getPaymentAccountPayload(),
|
||||
trade.getTaker().getPaymentAccountPayload(),
|
||||
contract.getMakerPayoutAddressString(),
|
||||
contract.getTakerPayoutAddressString(),
|
||||
contract.getLockTime());
|
||||
contract.getTakerPayoutAddressString());
|
||||
} else {
|
||||
contractInfo = ContractInfo.emptyContract.get();
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public final class OfferInfoBuilder {
|
|||
private String volume;
|
||||
private String minVolume;
|
||||
private long makerFee;
|
||||
private String offerFeePaymentTxId;
|
||||
private String offerFeeTxId;
|
||||
private long buyerSecurityDeposit;
|
||||
private long sellerSecurityDeposit;
|
||||
private String triggerPrice;
|
||||
|
@ -111,8 +111,8 @@ public final class OfferInfoBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
public OfferInfoBuilder withOfferFeePaymentTxId(String offerFeePaymentTxId) {
|
||||
this.offerFeePaymentTxId = offerFeePaymentTxId;
|
||||
public OfferInfoBuilder withOfferFeeTxId(String offerFeeTxId) {
|
||||
this.offerFeeTxId = offerFeeTxId;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -521,10 +521,10 @@ public class HavenoSetup {
|
|||
// resync.
|
||||
// TODO (woodser): check for invalid maker fee txs with xmr?
|
||||
// openOfferManager.getObservableList().forEach(e -> {
|
||||
// String offerFeePaymentTxId = e.getOffer().getOfferFeePaymentTxId();
|
||||
// if (btcWalletService.getConfidenceForTxId(offerFeePaymentTxId) == null) { // TODO (woodser): verify xmr maker fee tx
|
||||
// String offerFeeTxId = e.getOffer().getOfferFeeTxId();
|
||||
// if (btcWalletService.getConfidenceForTxId(offerFeeTxId) == null) { // TODO (woodser): verify xmr maker fee tx
|
||||
// String message = Res.get("popup.warning.openOfferWithInvalidMakerFeeTx",
|
||||
// e.getOffer().getShortId(), offerFeePaymentTxId);
|
||||
// e.getOffer().getShortId(), offerFeeTxId);
|
||||
// log.warn(message);
|
||||
// if (lockedUpFundsHandler != null) {
|
||||
// lockedUpFundsHandler.accept(message);
|
||||
|
|
|
@ -212,7 +212,7 @@ public class WalletAppSetup {
|
|||
UserThread.runAfter(() -> {
|
||||
String txId = newValue.getTxId();
|
||||
openOfferManager.getObservableList().stream()
|
||||
.filter(openOffer -> txId.equals(openOffer.getOffer().getOfferFeePaymentTxId()))
|
||||
.filter(openOffer -> txId.equals(openOffer.getOffer().getOfferFeeTxId()))
|
||||
.forEach(openOffer -> {
|
||||
// We delay to avoid concurrent modification exceptions
|
||||
UserThread.runAfter(() -> {
|
||||
|
@ -237,7 +237,7 @@ public class WalletAppSetup {
|
|||
if (txId.equals(trade.getTaker().getDepositTxHash())) {
|
||||
details = Res.get("popup.warning.trade.txRejected.deposit");
|
||||
}
|
||||
if (txId.equals(trade.getOffer().getOfferFeePaymentTxId())) {
|
||||
if (txId.equals(trade.getOffer().getOfferFeeTxId())) {
|
||||
details = Res.get("popup.warning.trade.txRejected.tradeFee");
|
||||
}
|
||||
|
||||
|
|
|
@ -275,8 +275,8 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
|||
return stateProperty;
|
||||
}
|
||||
|
||||
public void setOfferFeePaymentTxId(String offerFeePaymentTxID) {
|
||||
offerPayload.setOfferFeePaymentTxId(offerFeePaymentTxID);
|
||||
public void setOfferFeeTxId(String offerFeeTxId) {
|
||||
offerPayload.setOfferFeeTxId(offerFeeTxId);
|
||||
}
|
||||
|
||||
public void setErrorMessage(String errorMessage) {
|
||||
|
@ -483,8 +483,8 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
|||
return offerPayload.getMakerPaymentAccountId();
|
||||
}
|
||||
|
||||
public String getOfferFeePaymentTxId() {
|
||||
return offerPayload.getOfferFeePaymentTxId();
|
||||
public String getOfferFeeTxId() {
|
||||
return offerPayload.getOfferFeeTxId();
|
||||
}
|
||||
|
||||
public String getVersionNr() {
|
||||
|
|
|
@ -120,7 +120,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
|
|||
// Mutable property. Has to be set before offer is saved in P2P network as it changes the payload hash!
|
||||
@Setter
|
||||
@Nullable
|
||||
private String offerFeePaymentTxId;
|
||||
private String offerFeeTxId;
|
||||
@Nullable
|
||||
private final String countryCode;
|
||||
@Nullable
|
||||
|
@ -170,7 +170,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
|
|||
String counterCurrencyCode,
|
||||
String paymentMethodId,
|
||||
String makerPaymentAccountId,
|
||||
@Nullable String offerFeePaymentTxId,
|
||||
@Nullable String offerFeeTxId,
|
||||
@Nullable String countryCode,
|
||||
@Nullable List<String> acceptedCountryCodes,
|
||||
@Nullable String bankId,
|
||||
|
@ -213,7 +213,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
|
|||
this.reserveTxKeyImages = reserveTxKeyImages;
|
||||
this.marketPriceMarginPct = marketPriceMarginPct;
|
||||
this.useMarketBasedPrice = useMarketBasedPrice;
|
||||
this.offerFeePaymentTxId = offerFeePaymentTxId;
|
||||
this.offerFeeTxId = offerFeeTxId;
|
||||
this.countryCode = countryCode;
|
||||
this.acceptedCountryCodes = acceptedCountryCodes;
|
||||
this.bankId = bankId;
|
||||
|
@ -233,8 +233,8 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
|
|||
}
|
||||
|
||||
public byte[] getHash() {
|
||||
if (this.hash == null && this.offerFeePaymentTxId != null) {
|
||||
// A proto message can be created only after the offerFeePaymentTxId is
|
||||
if (this.hash == null && this.offerFeeTxId != null) {
|
||||
// A proto message can be created only after the offerFeeTxId is
|
||||
// set to a non-null value; now is the time to cache the payload hash.
|
||||
this.hash = Hash.getSha256Hash(this.toProtoMessage().toByteArray());
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
|
|||
.setIsPrivateOffer(isPrivateOffer)
|
||||
.setProtocolVersion(protocolVersion);
|
||||
Optional.ofNullable(arbitratorSigner).ifPresent(e -> builder.setArbitratorSigner(arbitratorSigner.toProtoMessage()));
|
||||
Optional.ofNullable(offerFeePaymentTxId).ifPresent(builder::setOfferFeePaymentTxId);
|
||||
Optional.ofNullable(offerFeeTxId).ifPresent(builder::setOfferFeeTxId);
|
||||
Optional.ofNullable(countryCode).ifPresent(builder::setCountryCode);
|
||||
Optional.ofNullable(bankId).ifPresent(builder::setBankId);
|
||||
Optional.ofNullable(acceptedBankIds).ifPresent(builder::addAllAcceptedBankIds);
|
||||
|
@ -331,7 +331,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
|
|||
proto.getCounterCurrencyCode(),
|
||||
proto.getPaymentMethodId(),
|
||||
proto.getMakerPaymentAccountId(),
|
||||
proto.getOfferFeePaymentTxId(),
|
||||
ProtoUtil.stringOrNullFromProto(proto.getOfferFeeTxId()),
|
||||
ProtoUtil.stringOrNullFromProto(proto.getCountryCode()),
|
||||
acceptedCountryCodes,
|
||||
ProtoUtil.stringOrNullFromProto(proto.getBankId()),
|
||||
|
@ -380,7 +380,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
|
|||
",\r\n reserveTxKeyImages=" + reserveTxKeyImages +
|
||||
",\r\n marketPriceMargin=" + marketPriceMarginPct +
|
||||
",\r\n useMarketBasedPrice=" + useMarketBasedPrice +
|
||||
",\r\n offerFeePaymentTxId='" + offerFeePaymentTxId + '\'' +
|
||||
",\r\n offerFeeTxId='" + offerFeeTxId + '\'' +
|
||||
",\r\n countryCode='" + countryCode + '\'' +
|
||||
",\r\n acceptedCountryCodes=" + acceptedCountryCodes +
|
||||
",\r\n bankId='" + bankId + '\'' +
|
||||
|
@ -422,7 +422,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
|
|||
object.add("counterCurrencyCode", context.serialize(offerPayload.getCounterCurrencyCode()));
|
||||
object.add("paymentMethodId", context.serialize(offerPayload.getPaymentMethodId()));
|
||||
object.add("makerPaymentAccountId", context.serialize(offerPayload.getMakerPaymentAccountId()));
|
||||
object.add("offerFeePaymentTxId", context.serialize(offerPayload.getOfferFeePaymentTxId()));
|
||||
object.add("offerFeeTxId", context.serialize(offerPayload.getOfferFeeTxId()));
|
||||
object.add("versionNr", context.serialize(offerPayload.getVersionNr()));
|
||||
object.add("blockHeightAtOfferCreation", context.serialize(offerPayload.getBlockHeightAtOfferCreation()));
|
||||
object.add("makerFee", context.serialize(offerPayload.getMakerFee()));
|
||||
|
|
|
@ -248,12 +248,12 @@ public class OfferUtil {
|
|||
}
|
||||
|
||||
public static Optional<String> getInvalidMakerFeeTxErrorMessage(Offer offer, BtcWalletService btcWalletService) {
|
||||
String offerFeePaymentTxId = offer.getOfferFeePaymentTxId();
|
||||
if (offerFeePaymentTxId == null) {
|
||||
String offerFeeTxId = offer.getOfferFeeTxId();
|
||||
if (offerFeeTxId == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
Transaction makerFeeTx = btcWalletService.getTransaction(offerFeePaymentTxId);
|
||||
Transaction makerFeeTx = btcWalletService.getTransaction(offerFeeTxId);
|
||||
if (makerFeeTx == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
|
|
@ -1322,7 +1322,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
|||
originalOfferPayload.getCounterCurrencyCode(),
|
||||
originalOfferPayload.getPaymentMethodId(),
|
||||
originalOfferPayload.getMakerPaymentAccountId(),
|
||||
originalOfferPayload.getOfferFeePaymentTxId(),
|
||||
originalOfferPayload.getOfferFeeTxId(),
|
||||
originalOfferPayload.getCountryCode(),
|
||||
originalOfferPayload.getAcceptedCountryCodes(),
|
||||
originalOfferPayload.getBankId(),
|
||||
|
|
|
@ -65,7 +65,6 @@ public class MakerReserveOfferFunds extends Task<PlaceOfferModel> {
|
|||
// save offer state
|
||||
model.setReserveTx(reserveTx);
|
||||
offer.getOfferPayload().setReserveTxKeyImages(reservedKeyImages);
|
||||
offer.setOfferFeePaymentTxId(reserveTx.getHash()); // TODO (woodser): don't use this field
|
||||
complete();
|
||||
} catch (Throwable t) {
|
||||
offer.setErrorMessage("An error occurred.\n" +
|
||||
|
|
|
@ -80,7 +80,7 @@ public class MempoolService {
|
|||
}
|
||||
|
||||
public void validateOfferMakerTx(OfferPayload offerPayload, Consumer<TxValidator> resultHandler) {
|
||||
validateOfferMakerTx(new TxValidator( offerPayload.getOfferFeePaymentTxId(), Coin.valueOf(offerPayload.getAmount())), resultHandler);
|
||||
validateOfferMakerTx(new TxValidator( offerPayload.getOfferFeeTxId(), Coin.valueOf(offerPayload.getAmount())), resultHandler);
|
||||
}
|
||||
|
||||
public void validateOfferMakerTx(TxValidator txValidator, Consumer<TxValidator> resultHandler) {
|
||||
|
|
|
@ -67,9 +67,6 @@ public final class Contract implements NetworkPayload {
|
|||
private final String makerDepositTxHash;
|
||||
private final String takerDepositTxHash;
|
||||
|
||||
// Added in v1.2.0
|
||||
private long lockTime;
|
||||
|
||||
public Contract(OfferPayload offerPayload,
|
||||
long tradeAmount,
|
||||
long tradePrice,
|
||||
|
@ -87,7 +84,6 @@ public final class Contract implements NetworkPayload {
|
|||
PubKeyRing takerPubKeyRing,
|
||||
String makerPayoutAddressString,
|
||||
String takerPayoutAddressString,
|
||||
long lockTime,
|
||||
String makerDepositTxHash,
|
||||
String takerDepositTxHash) {
|
||||
this.offerPayload = offerPayload;
|
||||
|
@ -107,7 +103,6 @@ public final class Contract implements NetworkPayload {
|
|||
this.takerPubKeyRing = takerPubKeyRing;
|
||||
this.makerPayoutAddressString = makerPayoutAddressString;
|
||||
this.takerPayoutAddressString = takerPayoutAddressString;
|
||||
this.lockTime = lockTime;
|
||||
this.makerDepositTxHash = makerDepositTxHash;
|
||||
this.takerDepositTxHash = takerDepositTxHash;
|
||||
|
||||
|
@ -143,7 +138,6 @@ public final class Contract implements NetworkPayload {
|
|||
PubKeyRing.fromProto(proto.getTakerPubKeyRing()),
|
||||
proto.getMakerPayoutAddressString(),
|
||||
proto.getTakerPayoutAddressString(),
|
||||
proto.getLockTime(),
|
||||
proto.getMakerDepositTxHash(),
|
||||
proto.getTakerDepositTxHash());
|
||||
}
|
||||
|
@ -168,7 +162,6 @@ public final class Contract implements NetworkPayload {
|
|||
.setTakerPubKeyRing(takerPubKeyRing.toProtoMessage())
|
||||
.setMakerPayoutAddressString(makerPayoutAddressString)
|
||||
.setTakerPayoutAddressString(takerPayoutAddressString)
|
||||
.setLockTime(lockTime)
|
||||
.setMakerDepositTxHash(makerDepositTxHash)
|
||||
.setTakerDepositTxHash(takerDepositTxHash)
|
||||
.build();
|
||||
|
@ -303,7 +296,6 @@ public final class Contract implements NetworkPayload {
|
|||
",\n takerPubKeyRing=" + takerPubKeyRing +
|
||||
",\n makerPayoutAddressString='" + makerPayoutAddressString + '\'' +
|
||||
",\n takerPayoutAddressString='" + takerPayoutAddressString + '\'' +
|
||||
",\n lockTime=" + lockTime +
|
||||
",\n makerDepositTxHash='" + makerDepositTxHash + '\'' +
|
||||
",\n takerDepositTxHash='" + takerDepositTxHash + '\'' +
|
||||
"\n}";
|
||||
|
|
|
@ -866,7 +866,6 @@ public abstract class Trade implements Tradable, Model {
|
|||
getTaker().getPubKeyRing(),
|
||||
this instanceof MakerTrade ? xmrWalletService.getAddressEntry(getId(), XmrAddressEntry.Context.TRADE_PAYOUT).get().getAddressString() : getMaker().getPayoutAddressString(), // maker payout address
|
||||
this instanceof TakerTrade ? xmrWalletService.getAddressEntry(getId(), XmrAddressEntry.Context.TRADE_PAYOUT).get().getAddressString() : getTaker().getPayoutAddressString(), // taker payout address
|
||||
getLockTime(),
|
||||
getMaker().getDepositTxHash(),
|
||||
getTaker().getDepositTxHash()
|
||||
);
|
||||
|
@ -1594,9 +1593,7 @@ public abstract class Trade implements Tradable, Model {
|
|||
}
|
||||
|
||||
public boolean isTxChainInvalid() {
|
||||
return offer.getOfferFeePaymentTxId() == null ||
|
||||
processModel.getMaker().getDepositTxHash() == null ||
|
||||
processModel.getTaker().getDepositTxHash() == null;
|
||||
return processModel.getMaker().getDepositTxHash() == null || processModel.getTaker().getDepositTxHash() == null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,14 +25,12 @@ import haveno.common.proto.persistable.PersistablePayload;
|
|||
import haveno.core.account.witness.AccountAgeWitness;
|
||||
import haveno.core.payment.payload.PaymentAccountPayload;
|
||||
import haveno.core.proto.CoreProtoResolver;
|
||||
import haveno.core.xmr.model.RawTransactionInput;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -82,15 +80,6 @@ public final class TradePeer implements PersistablePayload {
|
|||
private String contractAsJson;
|
||||
@Nullable
|
||||
private String contractSignature;
|
||||
@Nullable
|
||||
private byte[] signature;
|
||||
@Nullable
|
||||
private byte[] multiSigPubKey;
|
||||
@Nullable
|
||||
private List<RawTransactionInput> rawTransactionInputs;
|
||||
private long changeOutputValue;
|
||||
@Nullable
|
||||
private String changeOutputAddress;
|
||||
|
||||
// added in v 0.6
|
||||
@Nullable
|
||||
|
@ -145,8 +134,7 @@ public final class TradePeer implements PersistablePayload {
|
|||
|
||||
@Override
|
||||
public Message toProtoMessage() {
|
||||
final protobuf.TradePeer.Builder builder = protobuf.TradePeer.newBuilder()
|
||||
.setChangeOutputValue(changeOutputValue);
|
||||
final protobuf.TradePeer.Builder builder = protobuf.TradePeer.newBuilder();
|
||||
Optional.ofNullable(nodeAddress).ifPresent(e -> builder.setNodeAddress(nodeAddress.toProtoMessage()));
|
||||
Optional.ofNullable(pubKeyRing).ifPresent(e -> builder.setPubKeyRing(pubKeyRing.toProtoMessage()));
|
||||
Optional.ofNullable(accountId).ifPresent(builder::setAccountId);
|
||||
|
@ -159,11 +147,7 @@ public final class TradePeer implements PersistablePayload {
|
|||
Optional.ofNullable(payoutAddressString).ifPresent(builder::setPayoutAddressString);
|
||||
Optional.ofNullable(contractAsJson).ifPresent(builder::setContractAsJson);
|
||||
Optional.ofNullable(contractSignature).ifPresent(builder::setContractSignature);
|
||||
Optional.ofNullable(signature).ifPresent(e -> builder.setSignature(ByteString.copyFrom(e)));
|
||||
Optional.ofNullable(pubKeyRing).ifPresent(e -> builder.setPubKeyRing(e.toProtoMessage()));
|
||||
Optional.ofNullable(multiSigPubKey).ifPresent(e -> builder.setMultiSigPubKey(ByteString.copyFrom(e)));
|
||||
Optional.ofNullable(rawTransactionInputs).ifPresent(e -> builder.addAllRawTransactionInputs(ProtoUtil.collectionToProto(e, protobuf.RawTransactionInput.class)));
|
||||
Optional.ofNullable(changeOutputAddress).ifPresent(builder::setChangeOutputAddress);
|
||||
Optional.ofNullable(accountAgeWitnessNonce).ifPresent(e -> builder.setAccountAgeWitnessNonce(ByteString.copyFrom(e)));
|
||||
Optional.ofNullable(accountAgeWitnessSignature).ifPresent(e -> builder.setAccountAgeWitnessSignature(ByteString.copyFrom(e)));
|
||||
Optional.ofNullable(accountAgeWitness).ifPresent(e -> builder.setAccountAgeWitness(accountAgeWitness.toProtoAccountAgeWitness()));
|
||||
|
@ -192,7 +176,6 @@ public final class TradePeer implements PersistablePayload {
|
|||
TradePeer tradePeer = new TradePeer();
|
||||
tradePeer.setNodeAddress(proto.hasNodeAddress() ? NodeAddress.fromProto(proto.getNodeAddress()) : null);
|
||||
tradePeer.setPubKeyRing(proto.hasPubKeyRing() ? PubKeyRing.fromProto(proto.getPubKeyRing()) : null);
|
||||
tradePeer.setChangeOutputValue(proto.getChangeOutputValue());
|
||||
tradePeer.setAccountId(ProtoUtil.stringOrNullFromProto(proto.getAccountId()));
|
||||
tradePeer.setPaymentAccountId(ProtoUtil.stringOrNullFromProto(proto.getPaymentAccountId()));
|
||||
tradePeer.setPaymentMethodId(ProtoUtil.stringOrNullFromProto(proto.getPaymentMethodId()));
|
||||
|
@ -203,16 +186,7 @@ public final class TradePeer implements PersistablePayload {
|
|||
tradePeer.setPayoutAddressString(ProtoUtil.stringOrNullFromProto(proto.getPayoutAddressString()));
|
||||
tradePeer.setContractAsJson(ProtoUtil.stringOrNullFromProto(proto.getContractAsJson()));
|
||||
tradePeer.setContractSignature(ProtoUtil.stringOrNullFromProto(proto.getContractSignature()));
|
||||
tradePeer.setSignature(ProtoUtil.byteArrayOrNullFromProto(proto.getSignature()));
|
||||
tradePeer.setPubKeyRing(proto.hasPubKeyRing() ? PubKeyRing.fromProto(proto.getPubKeyRing()) : null);
|
||||
tradePeer.setMultiSigPubKey(ProtoUtil.byteArrayOrNullFromProto(proto.getMultiSigPubKey()));
|
||||
List<RawTransactionInput> rawTransactionInputs = proto.getRawTransactionInputsList().isEmpty() ?
|
||||
null :
|
||||
proto.getRawTransactionInputsList().stream()
|
||||
.map(RawTransactionInput::fromProto)
|
||||
.collect(Collectors.toList());
|
||||
tradePeer.setRawTransactionInputs(rawTransactionInputs);
|
||||
tradePeer.setChangeOutputAddress(ProtoUtil.stringOrNullFromProto(proto.getChangeOutputAddress()));
|
||||
tradePeer.setAccountAgeWitnessNonce(ProtoUtil.byteArrayOrNullFromProto(proto.getAccountAgeWitnessNonce()));
|
||||
tradePeer.setAccountAgeWitnessSignature(ProtoUtil.byteArrayOrNullFromProto(proto.getAccountAgeWitnessSignature()));
|
||||
protobuf.AccountAgeWitness protoAccountAgeWitness = proto.getAccountAgeWitness();
|
||||
|
|
|
@ -91,8 +91,10 @@ public class TradeStatisticsManager {
|
|||
if (!tradeStatistics.isValid()) {
|
||||
return;
|
||||
}
|
||||
observableTradeStatisticsSet.add(tradeStatistics);
|
||||
priceFeedService.applyLatestHavenoMarketPrice(observableTradeStatisticsSet);
|
||||
synchronized (observableTradeStatisticsSet) {
|
||||
observableTradeStatisticsSet.add(tradeStatistics);
|
||||
priceFeedService.applyLatestHavenoMarketPrice(observableTradeStatisticsSet);
|
||||
}
|
||||
maybeDumpStatistics();
|
||||
}
|
||||
});
|
||||
|
@ -102,8 +104,10 @@ public class TradeStatisticsManager {
|
|||
.map(e -> (TradeStatistics3) e)
|
||||
.filter(TradeStatistics3::isValid)
|
||||
.collect(Collectors.toSet());
|
||||
observableTradeStatisticsSet.addAll(set);
|
||||
priceFeedService.applyLatestHavenoMarketPrice(observableTradeStatisticsSet);
|
||||
synchronized (observableTradeStatisticsSet) {
|
||||
observableTradeStatisticsSet.addAll(set);
|
||||
priceFeedService.applyLatestHavenoMarketPrice(observableTradeStatisticsSet);
|
||||
}
|
||||
maybeDumpStatistics();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue