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;
|
package io.bisq.core.offer;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import io.bisq.common.locale.CurrencyUtil;
|
import io.bisq.common.locale.CurrencyUtil;
|
||||||
import io.bisq.common.locale.Res;
|
import io.bisq.common.locale.Res;
|
||||||
import io.bisq.common.monetary.Price;
|
import io.bisq.common.monetary.Price;
|
||||||
@ -43,6 +44,13 @@ public class OfferForJson {
|
|||||||
public long primaryMarketVolume;
|
public long primaryMarketVolume;
|
||||||
public long primaryMarketMinVolume;
|
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,
|
public OfferForJson(OfferPayload.Direction direction,
|
||||||
String currencyCode,
|
String currencyCode,
|
||||||
@ -71,11 +79,6 @@ public class OfferForJson {
|
|||||||
setDisplayStrings();
|
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() {
|
private void setDisplayStrings() {
|
||||||
try {
|
try {
|
||||||
final Price price = getPrice();
|
final Price price = getPrice();
|
||||||
@ -99,21 +102,6 @@ public class OfferForJson {
|
|||||||
primaryMarketMinVolume = getMinAmountAsCoin().getValue();
|
primaryMarketMinVolume = getMinAmountAsCoin().getValue();
|
||||||
primaryMarketVolume = getAmountAsCoin().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 {
|
} else {
|
||||||
primaryMarketDirection = direction;
|
primaryMarketDirection = direction;
|
||||||
currencyPair = Res.getBaseCurrencyCode() + "/" + currencyCode;
|
currencyPair = Res.getBaseCurrencyCode() + "/" + currencyCode;
|
||||||
@ -129,21 +117,6 @@ public class OfferForJson {
|
|||||||
primaryMarketAmount = getAmountAsCoin().getValue();
|
primaryMarketAmount = getAmountAsCoin().getValue();
|
||||||
primaryMarketMinVolume = getMinVolume().getValue();
|
primaryMarketMinVolume = getMinVolume().getValue();
|
||||||
primaryMarketVolume = getVolume().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) {
|
} catch (Throwable t) {
|
||||||
|
@ -86,12 +86,16 @@ public class TradeStatisticsManager implements PersistedDataHost {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// At startup the P2PDataStorage inits earlier, otherwise we ge the listener called.
|
// 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();
|
final StoragePayload storagePayload = e.getStoragePayload();
|
||||||
if (storagePayload instanceof TradeStatistics) {
|
if (storagePayload instanceof TradeStatistics)
|
||||||
add((TradeStatistics) storagePayload, false);
|
add((TradeStatistics) storagePayload, false);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
statisticsStorage.queueUpForSave(new TradeStatisticsList(new ArrayList<>(tradeStatisticsSet)), 2000);
|
||||||
|
dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(TradeStatistics tradeStatistics, boolean storeLocally) {
|
public void add(TradeStatistics tradeStatistics, boolean storeLocally) {
|
||||||
@ -101,10 +105,10 @@ public class TradeStatisticsManager implements PersistedDataHost {
|
|||||||
tradeStatisticsSet.add(tradeStatistics);
|
tradeStatisticsSet.add(tradeStatistics);
|
||||||
observableTradeStatisticsSet.add(tradeStatistics);
|
observableTradeStatisticsSet.add(tradeStatistics);
|
||||||
|
|
||||||
if (storeLocally)
|
if (storeLocally) {
|
||||||
statisticsStorage.queueUpForSave(new TradeStatisticsList(new ArrayList<>(tradeStatisticsSet)), 2000);
|
statisticsStorage.queueUpForSave(new TradeStatisticsList(new ArrayList<>(tradeStatisticsSet)), 2000);
|
||||||
|
|
||||||
dump();
|
dump();
|
||||||
|
}
|
||||||
} else {
|
} 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");
|
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