mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-20 02:12:00 +01:00
Fix missing ProtocolVersion in Offer.
Use getTTL() instead of Lombok Getter with instance field
This commit is contained in:
parent
22d90f627c
commit
b64457e869
@ -473,32 +473,32 @@ message OfferPayload {
|
||||
SELL = 2;
|
||||
}
|
||||
|
||||
Direction direction = 1;
|
||||
string base_currency_code = 2;
|
||||
string counter_currency_code = 3;
|
||||
string payment_method_id = 4;
|
||||
string country_code = 5;
|
||||
repeated string accepted_country_codes = 6;
|
||||
string bank_id = 7;
|
||||
repeated string accepted_bank_ids = 8;
|
||||
repeated NodeAddress arbitrator_node_addresses = 9;
|
||||
repeated NodeAddress mediator_node_addresses = 10;
|
||||
string id = 11;
|
||||
int64 date = 12;
|
||||
int64 protocol_version = 13;
|
||||
bool use_market_based_price = 14;
|
||||
int64 price = 15;
|
||||
double market_price_margin = 16;
|
||||
int64 amount = 17;
|
||||
int64 min_amount = 18;
|
||||
NodeAddress owner_node_address = 19;
|
||||
PubKeyRing pub_key_ring = 20;
|
||||
string maker_payment_account_id = 21;
|
||||
string offer_fee_payment_tx_id = 22;
|
||||
string version_nr = 23;
|
||||
int64 block_height_at_offer_creation = 24;
|
||||
int64 tx_fee = 25;
|
||||
int64 maker_fee = 26;
|
||||
string id = 1;
|
||||
int64 date = 2;
|
||||
NodeAddress owner_node_address = 3;
|
||||
PubKeyRing pub_key_ring = 4;
|
||||
Direction direction = 5;
|
||||
int64 price = 6;
|
||||
double market_price_margin = 7;
|
||||
bool use_market_based_price = 8;
|
||||
int64 amount = 9;
|
||||
int64 min_amount = 10;
|
||||
string base_currency_code = 11;
|
||||
string counter_currency_code = 12;
|
||||
repeated NodeAddress arbitrator_node_addresses = 13;
|
||||
repeated NodeAddress mediator_node_addresses = 14;
|
||||
string payment_method_id = 15;
|
||||
string maker_payment_account_id = 16;
|
||||
string offer_fee_payment_tx_id = 17;
|
||||
string country_code = 18;
|
||||
repeated string accepted_country_codes =19;
|
||||
string bank_id = 20;
|
||||
repeated string accepted_bank_ids = 21;
|
||||
string version_nr = 22;
|
||||
int64 block_height_at_offer_creation = 23;
|
||||
int64 tx_fee = 24;
|
||||
int64 maker_fee = 25;
|
||||
bool is_currency_for_maker_fee_btc = 26;
|
||||
int64 buyer_security_deposit = 27;
|
||||
int64 seller_security_deposit = 28;
|
||||
int64 max_trade_limit = 29;
|
||||
@ -510,7 +510,7 @@ message OfferPayload {
|
||||
bool is_private_offer = 35;
|
||||
string hash_of_challenge = 36;
|
||||
map<string, string> extra_data = 37;
|
||||
bool is_currency_for_maker_fee_btc = 38;
|
||||
int32 protocol_version = 38;
|
||||
}
|
||||
|
||||
// TODO not fully verified as impl. is not completed
|
||||
@ -913,8 +913,6 @@ message Tradable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
message Trade {
|
||||
enum State {
|
||||
PB_ERROR_STATE = 0;
|
||||
|
@ -41,7 +41,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ToString
|
||||
@Slf4j
|
||||
public final class Alert implements StoragePayload {
|
||||
private final long TTL = TimeUnit.DAYS.toMillis(30);
|
||||
private final String message;
|
||||
private final boolean isUpdateInfo;
|
||||
private final String version;
|
||||
@ -117,6 +116,11 @@ public final class Alert implements StoragePayload {
|
||||
// API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public long getTTL() {
|
||||
return TimeUnit.DAYS.toMillis(30);
|
||||
}
|
||||
|
||||
public void setSigAndPubKey(String signatureAsBase64, PublicKey ownerPubKey) {
|
||||
this.signatureAsBase64 = signatureAsBase64;
|
||||
this.ownerPubKey = ownerPubKey;
|
||||
|
@ -42,7 +42,6 @@ import java.util.stream.Collectors;
|
||||
@ToString
|
||||
@Getter
|
||||
public final class Arbitrator implements StoragePayload {
|
||||
public static final long TTL = TimeUnit.DAYS.toMillis(10);
|
||||
private final NodeAddress nodeAddress;
|
||||
private final byte[] btcPubKey;
|
||||
private final String btcAddress;
|
||||
@ -126,13 +125,13 @@ public final class Arbitrator implements StoragePayload {
|
||||
// API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public long getTTL() {
|
||||
return TimeUnit.DAYS.toMillis(10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublicKey getOwnerPubKey() {
|
||||
return pubKeyRing.getSignaturePubKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTTL() {
|
||||
return TTL;
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ import java.util.stream.Collectors;
|
||||
@ToString
|
||||
@Getter
|
||||
public final class Mediator implements StoragePayload {
|
||||
private final long TTL = TimeUnit.DAYS.toMillis(10);
|
||||
private final PubKeyRing pubKeyRing;
|
||||
private final NodeAddress nodeAddress;
|
||||
private final List<String> languageCodes;
|
||||
@ -116,6 +115,11 @@ public final class Mediator implements StoragePayload {
|
||||
// API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public long getTTL() {
|
||||
return TimeUnit.DAYS.toMillis(10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublicKey getOwnerPubKey() {
|
||||
return pubKeyRing.getSignaturePubKey();
|
||||
|
@ -43,7 +43,6 @@ import java.util.concurrent.TimeUnit;
|
||||
@Data
|
||||
// TODO There will be another object for PersistableEnvelope
|
||||
public final class CompensationRequestPayload implements LazyProcessedStoragePayload, PersistedStoragePayload, PersistableEnvelope {
|
||||
private final long TTL = TimeUnit.DAYS.toMillis(30);
|
||||
private final String uid;
|
||||
private final String name;
|
||||
private final String title;
|
||||
@ -185,6 +184,11 @@ public final class CompensationRequestPayload implements LazyProcessedStoragePay
|
||||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public long getTTL() {
|
||||
return TimeUnit.DAYS.toMillis(30);
|
||||
}
|
||||
|
||||
public Date getStartDate() {
|
||||
return new Date(startDate);
|
||||
}
|
||||
|
@ -43,7 +43,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public final class Filter implements StoragePayload {
|
||||
private final long TTL = TimeUnit.DAYS.toMillis(21);
|
||||
private final List<String> bannedOfferIds;
|
||||
private final List<String> bannedNodeAddress;
|
||||
private final List<PaymentAccountFilter> bannedPaymentAccounts;
|
||||
@ -120,6 +119,11 @@ public final class Filter implements StoragePayload {
|
||||
// API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public long getTTL() {
|
||||
return TimeUnit.DAYS.toMillis(30);
|
||||
}
|
||||
|
||||
public void setSigAndPubKey(String signatureAsBase64, PublicKey ownerPubKey) {
|
||||
this.signatureAsBase64 = signatureAsBase64;
|
||||
this.ownerPubKey = ownerPubKey;
|
||||
|
@ -60,10 +60,8 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
||||
@Getter
|
||||
private final OfferPayload offerPayload;
|
||||
@JsonExclude
|
||||
transient private Offer.State state = Offer.State.UNKNOWN;
|
||||
@JsonExclude
|
||||
@Getter
|
||||
transient private ObjectProperty<Offer.State> stateProperty = new SimpleObjectProperty<>(state);
|
||||
transient private ObjectProperty<Offer.State> stateProperty = new SimpleObjectProperty<>(Offer.State.UNKNOWN);
|
||||
@JsonExclude
|
||||
@Nullable
|
||||
transient private OfferAvailabilityProtocol availabilityProtocol;
|
||||
@ -211,7 +209,6 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void setState(Offer.State state) {
|
||||
this.state = state;
|
||||
stateProperty().set(state);
|
||||
}
|
||||
|
||||
@ -305,7 +302,7 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
||||
|
||||
// domain properties
|
||||
public Offer.State getState() {
|
||||
return state;
|
||||
return stateProperty.get();
|
||||
}
|
||||
|
||||
public ReadOnlyStringProperty errorMessageProperty() {
|
||||
@ -450,7 +447,7 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
||||
Offer offer = (Offer) o;
|
||||
|
||||
if (offerPayload != null ? !offerPayload.equals(offer.offerPayload) : offer.offerPayload != null) return false;
|
||||
if (state != offer.state) return false;
|
||||
if (getState() != offer.getState()) return false;
|
||||
return !(getErrorMessage() != null ? !getErrorMessage().equals(offer.getErrorMessage()) : offer.getErrorMessage() != null);
|
||||
|
||||
}
|
||||
@ -458,7 +455,7 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = offerPayload != null ? offerPayload.hashCode() : 0;
|
||||
result = 31 * result + (state != null ? state.hashCode() : 0);
|
||||
result = 31 * result + (getState() != null ? getState().hashCode() : 0);
|
||||
result = 31 * result + (getErrorMessage() != null ? getErrorMessage().hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
@ -467,7 +464,7 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
||||
public String toString() {
|
||||
return "Offer{" +
|
||||
"getErrorMessage()='" + getErrorMessage() + '\'' +
|
||||
", state=" + state +
|
||||
", state=" + getState() +
|
||||
", offerPayload=" + offerPayload +
|
||||
'}';
|
||||
}
|
||||
|
@ -17,11 +17,9 @@
|
||||
|
||||
package io.bisq.core.offer;
|
||||
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.crypto.PubKeyRing;
|
||||
import io.bisq.common.locale.CurrencyUtil;
|
||||
import io.bisq.common.proto.ProtoUtil;
|
||||
import io.bisq.common.util.JsonExclude;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
import io.bisq.network.p2p.storage.payload.RequiresOwnerIsOnlinePayload;
|
||||
@ -71,11 +69,32 @@ public final class OfferPayload implements StoragePayload, RequiresOwnerIsOnline
|
||||
// Instance fields
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private final long TTL = TimeUnit.MINUTES.toMillis(6);
|
||||
private final String id;
|
||||
private final long date;
|
||||
private final NodeAddress ownerNodeAddress;
|
||||
private final PubKeyRing pubKeyRing;
|
||||
private final Direction direction;
|
||||
// price if fixed price is used (usePercentageBasedPrice = false), otherwise 0
|
||||
private final long price;
|
||||
// Distance form market price if percentage based price is used (usePercentageBasedPrice = true), otherwise 0.
|
||||
// E.g. 0.1 -> 10%. Can be negative as well. Depending on direction the marketPriceMargin is above or below the market price.
|
||||
// Positive values is always the usual case where you want a better price as the market.
|
||||
// E.g. Buy offer with market price 400.- leads to a 360.- price.
|
||||
// Sell offer with market price 400.- leads to a 440.- price.
|
||||
private final double marketPriceMargin;
|
||||
// We use 2 type of prices: fixed price or price based on distance from market price
|
||||
private final boolean useMarketBasedPrice;
|
||||
private final long amount;
|
||||
private final long minAmount;
|
||||
private final String baseCurrencyCode;
|
||||
private final String counterCurrencyCode;
|
||||
private final List<NodeAddress> arbitratorNodeAddresses;
|
||||
private final List<NodeAddress> mediatorNodeAddresses;
|
||||
private final String paymentMethodId;
|
||||
private final String makerPaymentAccountId;
|
||||
// Mutable property. Has to be set before offer is save in P2P network as it changes the objects hash!
|
||||
@Nullable @Setter
|
||||
private String offerFeePaymentTxId;
|
||||
@Nullable
|
||||
private final String countryCode;
|
||||
@Nullable
|
||||
@ -84,34 +103,6 @@ public final class OfferPayload implements StoragePayload, RequiresOwnerIsOnline
|
||||
private final String bankId;
|
||||
@Nullable
|
||||
private final List<String> acceptedBankIds;
|
||||
private final List<NodeAddress> arbitratorNodeAddresses;
|
||||
private final List<NodeAddress> mediatorNodeAddresses;
|
||||
private final String id;
|
||||
private final long date;
|
||||
|
||||
// We use 2 type of prices: fixed price or price based on distance from market price
|
||||
private final boolean useMarketBasedPrice;
|
||||
// price if fixed price is used (usePercentageBasedPrice = false), otherwise 0
|
||||
private final long price;
|
||||
|
||||
// Distance form market price if percentage based price is used (usePercentageBasedPrice = true), otherwise 0.
|
||||
// E.g. 0.1 -> 10%. Can be negative as well. Depending on direction the marketPriceMargin is above or below the market price.
|
||||
// Positive values is always the usual case where you want a better price as the market.
|
||||
// E.g. Buy offer with market price 400.- leads to a 360.- price.
|
||||
// Sell offer with market price 400.- leads to a 440.- price.
|
||||
private final double marketPriceMargin;
|
||||
private final long amount;
|
||||
private final long minAmount;
|
||||
private final NodeAddress ownerNodeAddress;
|
||||
@JsonExclude
|
||||
private final PubKeyRing pubKeyRing;
|
||||
private final String makerPaymentAccountId;
|
||||
|
||||
// Mutable property. Has to be set before offer is save in P2P network as it changes the objects hash!
|
||||
@Setter
|
||||
private String offerFeePaymentTxId;
|
||||
|
||||
// New properties from v. 0.5.0.0
|
||||
private final String versionNr;
|
||||
private final long blockHeightAtOfferCreation;
|
||||
private final long txFee;
|
||||
@ -136,13 +127,12 @@ public final class OfferPayload implements StoragePayload, RequiresOwnerIsOnline
|
||||
private final boolean isPrivateOffer;
|
||||
@Nullable
|
||||
private final String hashOfChallenge;
|
||||
|
||||
// Should be only used in emergency case if we need to add data but do not want to break backward compatibility
|
||||
// at the P2P network storage checks. The hash of the object will be used to verify if the data is valid. Any new
|
||||
// field in a class would break that hash and therefore break the storage mechanism.
|
||||
@Nullable
|
||||
private final Map<String, String> extraDataMap;
|
||||
private final long protocolVersion;
|
||||
private final int protocolVersion;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -185,8 +175,8 @@ public final class OfferPayload implements StoragePayload, RequiresOwnerIsOnline
|
||||
long upperClosePrice,
|
||||
boolean isPrivateOffer,
|
||||
@Nullable String hashOfChallenge,
|
||||
@Nullable Map<String, String> extraDataMap) {
|
||||
|
||||
@Nullable Map<String, String> extraDataMap,
|
||||
int protocolVersion) {
|
||||
this.id = id;
|
||||
this.date = date;
|
||||
this.ownerNodeAddress = ownerNodeAddress;
|
||||
@ -224,10 +214,9 @@ public final class OfferPayload implements StoragePayload, RequiresOwnerIsOnline
|
||||
this.isPrivateOffer = isPrivateOffer;
|
||||
this.hashOfChallenge = hashOfChallenge;
|
||||
this.extraDataMap = extraDataMap;
|
||||
|
||||
protocolVersion = Version.TRADE_PROTOCOL_VERSION;
|
||||
this.protocolVersion = protocolVersion;
|
||||
}
|
||||
|
||||
//38
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PROTO BUFFER
|
||||
@ -272,8 +261,8 @@ public final class OfferPayload implements StoragePayload, RequiresOwnerIsOnline
|
||||
.setIsPrivateOffer(isPrivateOffer)
|
||||
.setProtocolVersion(protocolVersion);
|
||||
|
||||
checkNotNull(offerFeePaymentTxId, "OfferPayload is in invalid state: offerFeePaymentTxID is not set when adding to P2P network.");
|
||||
builder.setOfferFeePaymentTxId(offerFeePaymentTxId);
|
||||
builder.setOfferFeePaymentTxId(checkNotNull(offerFeePaymentTxId,
|
||||
"OfferPayload is in invalid state: offerFeePaymentTxID is not set when adding to P2P network."));
|
||||
|
||||
Optional.ofNullable(countryCode).ifPresent(builder::setCountryCode);
|
||||
Optional.ofNullable(bankId).ifPresent(builder::setBankId);
|
||||
@ -287,8 +276,6 @@ public final class OfferPayload implements StoragePayload, RequiresOwnerIsOnline
|
||||
|
||||
public static OfferPayload fromProto(PB.OfferPayload proto) {
|
||||
checkArgument(!proto.getOfferFeePaymentTxId().isEmpty(), "OfferFeePaymentTxId must be set in PB.OfferPayload");
|
||||
String countryCode = ProtoUtil.protoToNullableString(proto.getCountryCode());
|
||||
String bankId = ProtoUtil.protoToNullableString(proto.getBankId());
|
||||
List<String> acceptedBankIds = proto.getAcceptedBankIdsList().isEmpty() ?
|
||||
null : proto.getAcceptedBankIdsList().stream().collect(Collectors.toList());
|
||||
List<String> acceptedCountryCodes = proto.getAcceptedCountryCodesList().isEmpty() ?
|
||||
@ -317,9 +304,9 @@ public final class OfferPayload implements StoragePayload, RequiresOwnerIsOnline
|
||||
proto.getPaymentMethodId(),
|
||||
proto.getMakerPaymentAccountId(),
|
||||
proto.getOfferFeePaymentTxId(),
|
||||
countryCode,
|
||||
ProtoUtil.protoToNullableString(proto.getCountryCode()),
|
||||
acceptedCountryCodes,
|
||||
bankId,
|
||||
ProtoUtil.protoToNullableString(proto.getBankId()),
|
||||
acceptedBankIds,
|
||||
proto.getVersionNr(),
|
||||
proto.getBlockHeightAtOfferCreation(),
|
||||
@ -336,7 +323,8 @@ public final class OfferPayload implements StoragePayload, RequiresOwnerIsOnline
|
||||
proto.getUpperClosePrice(),
|
||||
proto.getIsPrivateOffer(),
|
||||
hashOfChallenge,
|
||||
extraDataMapMap);
|
||||
extraDataMapMap,
|
||||
proto.getProtocolVersion());
|
||||
}
|
||||
|
||||
|
||||
@ -344,6 +332,11 @@ public final class OfferPayload implements StoragePayload, RequiresOwnerIsOnline
|
||||
// API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public long getTTL() {
|
||||
return TimeUnit.MINUTES.toMillis(6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublicKey getOwnerPubKey() {
|
||||
return pubKeyRing.getSignaturePubKey();
|
||||
|
@ -126,7 +126,6 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
||||
@Override
|
||||
public void readPersisted() {
|
||||
openOffers = new TradableList<>(openOfferTradableListStorage, "OpenOffers");
|
||||
openOffers.readPersisted();
|
||||
openOffers.forEach(e -> e.getOffer().setPriceFeedService(priceFeedService));
|
||||
}
|
||||
|
||||
|
@ -18,10 +18,9 @@
|
||||
package io.bisq.core.trade;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.DevEnv;
|
||||
import io.bisq.common.proto.ProtoUtil;
|
||||
import io.bisq.common.proto.ProtobufferException;
|
||||
import io.bisq.common.proto.persistable.PersistableEnvelope;
|
||||
import io.bisq.common.proto.persistable.PersistedDataHost;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import io.bisq.core.btc.wallet.BtcWalletService;
|
||||
import io.bisq.core.offer.OpenOffer;
|
||||
@ -29,6 +28,7 @@ import io.bisq.core.proto.CoreProtoResolver;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -38,9 +38,9 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Slf4j
|
||||
public final class TradableList<T extends Tradable> implements PersistableEnvelope, PersistedDataHost {
|
||||
public final class TradableList<T extends Tradable> implements PersistableEnvelope {
|
||||
transient final private Storage<TradableList<T>> storage;
|
||||
private String fileName;
|
||||
@Getter
|
||||
private final ObservableList<T> list = FXCollections.observableArrayList();
|
||||
|
||||
|
||||
@ -50,16 +50,13 @@ public final class TradableList<T extends Tradable> implements PersistableEnvelo
|
||||
|
||||
public TradableList(Storage<TradableList<T>> storage, String fileName) {
|
||||
this.storage = storage;
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPersisted() {
|
||||
TradableList<T> persisted = storage.initAndGetPersisted(this, fileName);
|
||||
if (persisted != null)
|
||||
list.addAll(persisted.getList());
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PROTO BUFFER
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -71,14 +68,16 @@ public final class TradableList<T extends Tradable> implements PersistableEnvelo
|
||||
|
||||
@Override
|
||||
public Message toProtoMessage() {
|
||||
return PB.PersistableEnvelope.newBuilder().setTradableList(PB.TradableList.newBuilder()
|
||||
.addAllTradable(ProtoUtil.collectionToProto(list))).build();
|
||||
return PB.PersistableEnvelope.newBuilder()
|
||||
.setTradableList(PB.TradableList.newBuilder()
|
||||
.addAllTradable(ProtoUtil.collectionToProto(list)))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static TradableList fromProto(PB.TradableList proto,
|
||||
CoreProtoResolver coreProtoResolver,
|
||||
Storage<TradableList<Tradable>> tradableListStorage,
|
||||
Storage<TradableList<Tradable>> storage,
|
||||
BtcWalletService btcWalletService) {
|
||||
log.debug("TradableList fromProto of {} ", proto);
|
||||
|
||||
@ -88,24 +87,21 @@ public final class TradableList<T extends Tradable> implements PersistableEnvelo
|
||||
case OPEN_OFFER:
|
||||
return OpenOffer.fromProto(tradable.getOpenOffer());
|
||||
case BUYER_AS_MAKER_TRADE:
|
||||
return BuyerAsMakerTrade.fromProto(tradable.getBuyerAsMakerTrade(), tradableListStorage, btcWalletService, coreProtoResolver);
|
||||
return BuyerAsMakerTrade.fromProto(tradable.getBuyerAsMakerTrade(), storage, btcWalletService, coreProtoResolver);
|
||||
case BUYER_AS_TAKER_TRADE:
|
||||
return BuyerAsTakerTrade.fromProto(tradable.getBuyerAsTakerTrade(), tradableListStorage, btcWalletService, coreProtoResolver);
|
||||
return BuyerAsTakerTrade.fromProto(tradable.getBuyerAsTakerTrade(), storage, btcWalletService, coreProtoResolver);
|
||||
case SELLER_AS_MAKER_TRADE:
|
||||
return SellerAsMakerTrade.fromProto(tradable.getSellerAsMakerTrade(), tradableListStorage, btcWalletService, coreProtoResolver);
|
||||
return SellerAsMakerTrade.fromProto(tradable.getSellerAsMakerTrade(), storage, btcWalletService, coreProtoResolver);
|
||||
case SELLER_AS_TAKER_TRADE:
|
||||
return SellerAsTakerTrade.fromProto(tradable.getSellerAsTakerTrade(), tradableListStorage, btcWalletService, coreProtoResolver);
|
||||
return SellerAsTakerTrade.fromProto(tradable.getSellerAsTakerTrade(), storage, btcWalletService, coreProtoResolver);
|
||||
default:
|
||||
log.error("Unknown messageCase. tradable.getMessageCase() = " + tradable.getMessageCase());
|
||||
if (DevEnv.DEV_MODE)
|
||||
throw new RuntimeException("Unknown messageCase. tradable.getMessageCase() = " + tradable.getMessageCase());
|
||||
return null;
|
||||
throw new ProtobufferException("Unknown messageCase. tradable.getMessageCase() = " + tradable.getMessageCase());
|
||||
}
|
||||
})
|
||||
.filter(e -> e != null)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return new TradableList<>(tradableListStorage, list);
|
||||
return new TradableList<>(storage, list);
|
||||
}
|
||||
|
||||
|
||||
@ -121,18 +117,18 @@ public final class TradableList<T extends Tradable> implements PersistableEnvelo
|
||||
}
|
||||
|
||||
public boolean remove(T tradable) {
|
||||
boolean changed = this.list.remove(tradable);
|
||||
boolean changed = list.remove(tradable);
|
||||
if (changed)
|
||||
storage.queueUpForSave();
|
||||
return changed;
|
||||
}
|
||||
|
||||
public Stream<T> stream() {
|
||||
return this.list.stream();
|
||||
return list.stream();
|
||||
}
|
||||
|
||||
public void forEach(Consumer<? super T> action) {
|
||||
this.list.forEach(action);
|
||||
list.forEach(action);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
@ -142,8 +138,4 @@ public final class TradableList<T extends Tradable> implements PersistableEnvelo
|
||||
public boolean contains(T thing) {
|
||||
return list.contains(thing);
|
||||
}
|
||||
|
||||
public ObservableList<T> getList() {
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +168,6 @@ public class TradeManager implements PersistedDataHost {
|
||||
@Override
|
||||
public void readPersisted() {
|
||||
tradableList = new TradableList<>(tradableListStorage, "PendingTrades");
|
||||
tradableList.readPersisted();
|
||||
tradableList.forEach(trade -> {
|
||||
trade.setTransientFields(tradableListStorage, btcWalletService);
|
||||
trade.getOffer().setPriceFeedService(priceFeedService);
|
||||
|
@ -58,7 +58,6 @@ public class ClosedTradableManager implements PersistedDataHost {
|
||||
@Override
|
||||
public void readPersisted() {
|
||||
closedTrades = new TradableList<>(tradableListStorage, "ClosedTrades");
|
||||
closedTrades.readPersisted();
|
||||
closedTrades.forEach(tradable -> {
|
||||
tradable.getOffer().setPriceFeedService(priceFeedService);
|
||||
if (tradable instanceof Trade) {
|
||||
|
@ -58,7 +58,6 @@ public class FailedTradesManager implements PersistedDataHost {
|
||||
@Override
|
||||
public void readPersisted() {
|
||||
this.failedTrades = new TradableList<>(tradableListStorage, "FailedTrades");
|
||||
failedTrades.readPersisted();
|
||||
failedTrades.forEach(e -> e.getOffer().setPriceFeedService(priceFeedService));
|
||||
failedTrades.forEach(trade -> {
|
||||
trade.getOffer().setPriceFeedService(priceFeedService);
|
||||
|
@ -35,7 +35,6 @@ import java.util.concurrent.TimeUnit;
|
||||
@Value
|
||||
public final class TradeStatistics implements LazyProcessedStoragePayload, PersistedStoragePayload /*,CapabilityRequiringPayload*/ {
|
||||
@JsonExclude
|
||||
private final long TTL = TimeUnit.DAYS.toMillis(30);
|
||||
private final OfferPayload.Direction direction;
|
||||
private final String baseCurrency;
|
||||
private final String counterCurrency;
|
||||
@ -172,6 +171,11 @@ public final class TradeStatistics implements LazyProcessedStoragePayload, Persi
|
||||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public long getTTL() {
|
||||
return TimeUnit.DAYS.toMillis(30);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublicKey getOwnerPubKey() {
|
||||
return pubKeyRing.getSignaturePubKey();
|
||||
|
@ -394,7 +394,8 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
||||
lowerClosePrice,
|
||||
isPrivateOffer,
|
||||
hashOfChallenge,
|
||||
extraDataMap);
|
||||
extraDataMap,
|
||||
Version.TRADE_PROTOCOL_VERSION);
|
||||
Offer offer = new Offer(offerPayload);
|
||||
offer.setPriceFeedService(priceFeedService);
|
||||
return offer;
|
||||
|
@ -74,7 +74,8 @@ public class TradesChartsViewModelTest {
|
||||
0,
|
||||
false,
|
||||
null,
|
||||
null
|
||||
null,
|
||||
1
|
||||
);
|
||||
|
||||
set.add(new TradeStatistics(offer, Price.parse("520", "EUR"), Coin.parseCoin("1"), new Date(now.getTime()), null, null));
|
||||
|
@ -301,6 +301,7 @@ public class OfferBookViewModelTest {
|
||||
0,
|
||||
false,
|
||||
null,
|
||||
null));
|
||||
null,
|
||||
1));
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ import java.util.concurrent.TimeUnit;
|
||||
@EqualsAndHashCode
|
||||
@Slf4j
|
||||
public final class MailboxStoragePayload implements StoragePayload {
|
||||
private final long TTL = TimeUnit.DAYS.toMillis(10);
|
||||
private final PrefixedSealedAndSignedMessage prefixedSealedAndSignedMessage;
|
||||
private PublicKey senderPubKeyForAddOperation;
|
||||
private final byte[] senderPubKeyForAddOperationBytes;
|
||||
@ -85,4 +84,14 @@ public final class MailboxStoragePayload implements StoragePayload {
|
||||
proto.getOwnerPubKeyBytes().toByteArray(),
|
||||
CollectionUtils.isEmpty(proto.getExtraDataMap()) ? null : proto.getExtraDataMap());
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public long getTTL() {
|
||||
return TimeUnit.DAYS.toMillis(15);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user