use of bisq.core.locale.CurrencyTuple in project bisq-core by bisq-network.
the class TradeStatisticsManager method onAllServicesInitialized.
public void onAllServicesInitialized() {
if (dumpStatistics) {
ArrayList<CurrencyTuple> fiatCurrencyList = new ArrayList<>(CurrencyUtil.getAllSortedFiatCurrencies().stream().map(e -> new CurrencyTuple(e.getCode(), e.getName(), 8)).collect(Collectors.toList()));
jsonFileManager.writeToDisc(Utilities.objectToJson(fiatCurrencyList), "fiat_currency_list");
ArrayList<CurrencyTuple> cryptoCurrencyList = new ArrayList<>(CurrencyUtil.getAllSortedCryptoCurrencies().stream().map(e -> new CurrencyTuple(e.getCode(), e.getName(), 8)).collect(Collectors.toList()));
cryptoCurrencyList.add(0, new CurrencyTuple(Res.getBaseCurrencyCode(), Res.getBaseCurrencyName(), 8));
jsonFileManager.writeToDisc(Utilities.objectToJson(cryptoCurrencyList), "crypto_currency_list");
}
p2PService.getP2PDataStorage().addPersistableNetworkPayloadMapListener(payload -> {
if (payload instanceof TradeStatistics2)
addToMap((TradeStatistics2) payload, true);
});
p2PService.getP2PDataStorage().getPersistableNetworkPayloadList().getMap().values().forEach(e -> {
if (e instanceof TradeStatistics2)
addToMap((TradeStatistics2) e, false);
});
// TODO can be removed after version older than v0.6.0 are not used anymore
// We listen to TradeStatistics objects from old clients as well and convert them into TradeStatistics2 objects
p2PService.addHashSetChangedListener(new HashMapChangedListener() {
@Override
public void onAdded(ProtectedStorageEntry data) {
final ProtectedStoragePayload protectedStoragePayload = data.getProtectedStoragePayload();
if (protectedStoragePayload instanceof TradeStatistics)
p2PService.getP2PDataStorage().addPersistableNetworkPayload(ConvertToTradeStatistics2((TradeStatistics) protectedStoragePayload), p2PService.getNetworkNode().getNodeAddress(), true, false, false, false);
}
@Override
public void onRemoved(ProtectedStorageEntry data) {
// We don't remove items
}
});
priceFeedService.applyLatestBisqMarketPrice(tradeStatisticsSet);
dump();
// print all currencies sorted by nr. of trades
// printAllCurrencyStats();
}
Aggregations