mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-20 10:22:18 +01:00
Fix transient fields on OfferForJson. Dont dump json in iteration but after.
This commit is contained in:
parent
3f164e7923
commit
93eecd17e4
@ -1,5 +1,6 @@
|
||||
package io.bisq.core.offer;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.bisq.common.locale.CurrencyUtil;
|
||||
import io.bisq.common.locale.Res;
|
||||
import io.bisq.common.monetary.Price;
|
||||
@ -43,6 +44,13 @@ public class OfferForJson {
|
||||
public long primaryMarketVolume;
|
||||
public long primaryMarketMinVolume;
|
||||
|
||||
@JsonIgnore
|
||||
transient private final MonetaryFormat fiatFormat = new MonetaryFormat().shift(0).minDecimals(4).repeatOptionalDecimals(0, 0);
|
||||
@JsonIgnore
|
||||
transient private final MonetaryFormat altcoinFormat = new MonetaryFormat().shift(0).minDecimals(8).repeatOptionalDecimals(0, 0);
|
||||
@JsonIgnore
|
||||
transient private final MonetaryFormat coinFormat = MonetaryFormat.BTC;
|
||||
|
||||
|
||||
public OfferForJson(OfferPayload.Direction direction,
|
||||
String currencyCode,
|
||||
@ -71,11 +79,6 @@ public class OfferForJson {
|
||||
setDisplayStrings();
|
||||
}
|
||||
|
||||
protected final MonetaryFormat fiatFormat = new MonetaryFormat().shift(0).minDecimals(4).repeatOptionalDecimals(0, 0);
|
||||
protected final MonetaryFormat altcoinFormat = new MonetaryFormat().shift(0).minDecimals(8).repeatOptionalDecimals(0, 0);
|
||||
protected final MonetaryFormat coinFormat = MonetaryFormat.BTC;
|
||||
//protected final DecimalFormat decimalFormat = new DecimalFormat("#.#");
|
||||
|
||||
private void setDisplayStrings() {
|
||||
try {
|
||||
final Price price = getPrice();
|
||||
@ -99,21 +102,6 @@ public class OfferForJson {
|
||||
primaryMarketMinVolume = getMinAmountAsCoin().getValue();
|
||||
primaryMarketVolume = getAmountAsCoin().getValue();
|
||||
|
||||
|
||||
//final double value = price.value != 0 ? price.value / 100000000D : 0;
|
||||
// priceDisplayString = decimalFormat.format(MathUtils.roundDouble(value, precision)).replace(",", ".");
|
||||
// primaryMarketMinAmountDisplayString = altcoinFormat.noCode().format(getMinVolume()).toString();
|
||||
// primaryMarketAmountDisplayString = altcoinFormat.noCode().format(getVolume()).toString();
|
||||
// primaryMarketMinVolumeDisplayString = coinFormat.noCode().format(getMinAmountAsCoin()).toString();
|
||||
// primaryMarketVolumeDisplayString = coinFormat.noCode().format(getAmountAsCoin()).toString();
|
||||
|
||||
|
||||
/*primaryMarketPrice = MathUtils.roundDoubleToLong(MathUtils.scaleUpByPowerOf10(value, precision));
|
||||
primaryMarketMinAmount = (long) MathUtils.scaleUpByPowerOf10(getMinVolume().longValue(), precision);
|
||||
primaryMarketAmount = (long) MathUtils.scaleUpByPowerOf10(getVolume().longValue(), precision);
|
||||
primaryMarketMinVolume = getMinAmountAsCoin().longValue();
|
||||
primaryMarketVolume = getAmountAsCoin().longValue();*/
|
||||
|
||||
} else {
|
||||
primaryMarketDirection = direction;
|
||||
currencyPair = Res.getBaseCurrencyCode() + "/" + currencyCode;
|
||||
@ -129,21 +117,6 @@ public class OfferForJson {
|
||||
primaryMarketAmount = getAmountAsCoin().getValue();
|
||||
primaryMarketMinVolume = getMinVolume().getValue();
|
||||
primaryMarketVolume = getVolume().getValue();
|
||||
|
||||
/*
|
||||
priceDisplayString = fiatFormat.noCode().format(price.getMonetary()).toString();
|
||||
|
||||
primaryMarketMinAmountDisplayString = coinFormat.noCode().format(getMinAmountAsCoin()).toString();
|
||||
primaryMarketAmountDisplayString = coinFormat.noCode().format(getAmountAsCoin()).toString();
|
||||
primaryMarketMinVolumeDisplayString = fiatFormat.noCode().format(getMinVolume().getMonetary()).toString();
|
||||
primaryMarketVolumeDisplayString = fiatFormat.noCode().format(getVolume().getMonetary()).toString();
|
||||
|
||||
int precision = 4;
|
||||
primaryMarketPrice = (long) MathUtils.scaleUpByPowerOf10(price.getValue(), precision);
|
||||
primaryMarketMinAmount = getMinAmountAsCoin().getValue();
|
||||
primaryMarketAmount = getAmountAsCoin().getValue();
|
||||
primaryMarketMinVolume = (long) MathUtils.scaleUpByPowerOf10(getMinVolume().getValue(), precision);
|
||||
primaryMarketVolume = (long) MathUtils.scaleUpByPowerOf10(getVolume().getValue(), precision);*/
|
||||
}
|
||||
|
||||
} catch (Throwable t) {
|
||||
|
@ -86,12 +86,16 @@ public class TradeStatisticsManager implements PersistedDataHost {
|
||||
});
|
||||
|
||||
// At startup the P2PDataStorage inits earlier, otherwise we ge the listener called.
|
||||
p2PService.getP2PDataStorage().getMap().values().forEach(e -> {
|
||||
final List<ProtectedStorageEntry> list = new ArrayList<>(p2PService.getP2PDataStorage().getMap().values());
|
||||
list.forEach(e -> {
|
||||
final StoragePayload storagePayload = e.getStoragePayload();
|
||||
if (storagePayload instanceof TradeStatistics) {
|
||||
if (storagePayload instanceof TradeStatistics)
|
||||
add((TradeStatistics) storagePayload, false);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
statisticsStorage.queueUpForSave(new TradeStatisticsList(new ArrayList<>(tradeStatisticsSet)), 2000);
|
||||
dump();
|
||||
}
|
||||
|
||||
public void add(TradeStatistics tradeStatistics, boolean storeLocally) {
|
||||
@ -101,10 +105,10 @@ public class TradeStatisticsManager implements PersistedDataHost {
|
||||
tradeStatisticsSet.add(tradeStatistics);
|
||||
observableTradeStatisticsSet.add(tradeStatistics);
|
||||
|
||||
if (storeLocally)
|
||||
if (storeLocally) {
|
||||
statisticsStorage.queueUpForSave(new TradeStatisticsList(new ArrayList<>(tradeStatisticsSet)), 2000);
|
||||
|
||||
dump();
|
||||
}
|
||||
} else {
|
||||
log.debug("We have already an item with the same offer ID. That might happen if both the maker and the taker published the tradeStatistics");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user