Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GUI labels to reflect multiple rate providers #4406

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 9 additions & 20 deletions core/src/main/java/bisq/core/provider/price/PriceFeedService.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class PriceFeedService {
private String currencyCode;
private final StringProperty currencyCodeProperty = new SimpleStringProperty();
private final IntegerProperty updateCounter = new SimpleIntegerProperty(0);
private long epochInSecondAtLastRequest;
private long epochInMillisAtLastRequest;
private Map<String, Long> timeStampMap = new HashMap<>();
private long retryDelay = 1;
private long requestTs;
Expand Down Expand Up @@ -280,24 +280,8 @@ public ReadOnlyIntegerProperty updateCounterProperty() {
return updateCounter;
}

public Date getLastRequestTimeStampBtcAverage() {
return new Date(epochInSecondAtLastRequest);
}

public Date getLastRequestTimeStampPoloniex() {
Long ts = timeStampMap.get("btcAverageTs");
if (ts != null) {
return new Date(ts);
} else
return new Date();
}

public Date getLastRequestTimeStampCoinmarketcap() {
Long ts = timeStampMap.get("coinmarketcapTs");
if (ts != null) {
return new Date(ts);
} else
return new Date();
public Date getLastRequestTimeStamp() {
return new Date(epochInMillisAtLastRequest);
}

public void applyLatestBisqMarketPrice(Set<TradeStatistics2> tradeStatisticsSet) {
Expand Down Expand Up @@ -400,7 +384,12 @@ public void onSuccess(@Nullable Tuple2<Map<String, Long>, Map<String, MarketPric
UserThread.execute(() -> {
checkNotNull(result, "Result must not be null at requestAllPrices");
timeStampMap = result.first;
epochInSecondAtLastRequest = timeStampMap.get("btcAverageTs");

// Each currency rate has a different timestamp, depending on when
// the pricenode aggregate rate was calculated
// However, the request timestamp is when the pricenode was queried
epochInMillisAtLastRequest = System.currentTimeMillis();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hold on a second, this isn't just changing labels, you're actually changing code here. It looks like you're replacing the timestamp of the actual price data, with the timestamp Bisq updated it from the Pricenode, which is incorrect. This behavior needs to be preserved, for example if a pricenode has an issue and doesn't get data updates, the local Bisq node needs to be able to detect that it's old data and switch to a different Pricenode with recently updated data.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there is no more BA provider, the btcAverageTs field is basically useless.

It is however used here to populate the epochInMillisAtLastRequest timestamp -- which is used in the UI to show when the fiat rates were retrieved.

Before, when using BA: this made sense, cause BA was the "single source of truth" for all fiat rates, and Poloniex was the source of alt rates.

Now, when using multiple providers: basically the pricenode itself is the "provider", because it aggregates rates from multiple sources for both fiat and alts.

So, the closest "timestamp" that shows the last time the "provider" (pricenode) was polled, is the one in the code snippet above.

Alternative would be to extract and index every timestamp per exchange rate, then selectively show the right one depending on what currency pair the user selected in the UI. That seems like overkill for what this change tries to achieve. Especially since those "per exchange rate" timestamps are very likely the same, cause they all show the point in time when the avg rate was calculated, and they're all calculated when the pricenode is polled (the avg is freshly calculated based on newest data).

So I would say, this is the simplest and most pragmatic approach (epochInMillisAtLastRequest = timestamp_when_pricenode_last_successfully_queried).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timestamp is not for when the data was updated from the pricenode, that's irrelevant. The timestamp is for the price itself, i.e. when the price was obtained from the provider, or in the case of a weighted average aka index, the time when the index was last updated. Can you please use the timestampSec field for each asset's index?

Copy link
Contributor Author

@cd2357 cd2357 Aug 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. This field now just stores the "pricenode query timestamp", but the timestampSec of each asset is shown in the tooltip (see PR screenshots).


final Map<String, MarketPrice> priceMap = result.second;

cache.putAll(priceMap);
Expand Down
1 change: 0 additions & 1 deletion core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ mainView.marketPrice.bisqInternalPrice=Price of latest Bisq trade
mainView.marketPrice.tooltip.bisqInternalPrice=There is no market price from external price feed providers available.\n\
The displayed price is the latest Bisq trade price for that currency.
mainView.marketPrice.tooltip=Market price is provided by {0}{1}\nLast update: {2}\nProvider node URL: {3}
mainView.marketPrice.tooltip.altcoinExtra=If the altcoin is not available at Poloniex we use https://coinmarketcap.com
mainView.balance.available=Available balance
mainView.balance.reserved=Reserved in offers
mainView.balance.locked=Locked in trades
Expand Down
1 change: 0 additions & 1 deletion core/src/main/resources/i18n/displayStrings_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ mainView.marketPriceWithProvider.label=Marktpreis von {0}
mainView.marketPrice.bisqInternalPrice=Preis des letzten Bisq-Handels
mainView.marketPrice.tooltip.bisqInternalPrice=Es ist kein Marktpreis von externen Marktpreis-Anbietern verfügbar.\nDer angezeigte Preis, ist der letzte Bisq-Handelspreis für diese Währung.
mainView.marketPrice.tooltip=Marktpreis bereitgestellt von {0}{1}\nLetzte Aktualisierung: {2}\nURL des Knoten-Anbieters: {3}
mainView.marketPrice.tooltip.altcoinExtra=Falls der Altcoin nicht auf Poloniex verfügbar ist nutzen wir https://coinmarketcap.com
mainView.balance.available=Verfügbarer Betrag
mainView.balance.reserved=In Angeboten reserviert
mainView.balance.locked=In Trades gesperrt
Expand Down
1 change: 0 additions & 1 deletion core/src/main/resources/i18n/displayStrings_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ mainView.marketPriceWithProvider.label=Precio de mercado por {0}
mainView.marketPrice.bisqInternalPrice=Precio del último intercambio en Bisq
mainView.marketPrice.tooltip.bisqInternalPrice=No existe un precio de mercado disponible proveniente de fuentes externas.\nEl precio mostrado es el último precio de intercambio en Bisq para esa moneda.
mainView.marketPrice.tooltip=Precio de mercado ofrecido por {0}{1}\nÚltima actualización: {2}\nURL del nodo proveedor: {3}
mainView.marketPrice.tooltip.altcoinExtra=Si la altcoin no está disponible en Poloniex usamos https://coinmarketcap.com
mainView.balance.available=Saldo disponible
mainView.balance.reserved=Reservado en ofertas
mainView.balance.locked=Bloqueado en intercambios
Expand Down
1 change: 0 additions & 1 deletion core/src/main/resources/i18n/displayStrings_fa.properties
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ mainView.marketPriceWithProvider.label=قیمت بازار بر اساس {0}
mainView.marketPrice.bisqInternalPrice=قیمت آخرین معامله‌ی Bisq
mainView.marketPrice.tooltip.bisqInternalPrice=قیمت بازارهای خارجی موجود نیست.\nقیمت نمایش داده شده، از آخرین معامله‌ی Bisq برای ارز موردنظر اتخاذ شده است.
mainView.marketPrice.tooltip=قیمت بازار توسط {0}{1} ارائه شده است\nآخرین به روز رسانی: {2}\nURL لینک Node ارائه دهنده: {3}
mainView.marketPrice.tooltip.altcoinExtra=در صورتی که آلتکوین در Poloniex موجود نباشد، از نرخ https://coinmarketcap.com استفاده می کنیم.
mainView.balance.available=موجودی در دسترس
mainView.balance.reserved=رزرو شده در پیشنهادها
mainView.balance.locked=قفل شده در معاملات
Expand Down
1 change: 0 additions & 1 deletion core/src/main/resources/i18n/displayStrings_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ mainView.marketPriceWithProvider.label=Prix du marché par {0}
mainView.marketPrice.bisqInternalPrice=Cours de la dernière transaction Bisq
mainView.marketPrice.tooltip.bisqInternalPrice=Il n'y a pas de cours de marché disponible depuis une source externe.\nLe cours affiché est celui de la dernière transaction Bisq pour cette devise.
mainView.marketPrice.tooltip=Le prix de marché est fourni par {0}{1}\nDernière mise à jour: {2}\nURL du noeud: {3}
mainView.marketPrice.tooltip.altcoinExtra=Si l'altcoin n'est pas disponible sur Poloniex nous utilisons https://coinmarketcap.com
mainView.balance.available=Solde disponible
mainView.balance.reserved=Réservé en ordres
mainView.balance.locked=Bloqué en transactions
Expand Down
1 change: 0 additions & 1 deletion core/src/main/resources/i18n/displayStrings_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ mainView.marketPriceWithProvider.label={0} による市場価格
mainView.marketPrice.bisqInternalPrice=Bisqにおける最新の取引価格
mainView.marketPrice.tooltip.bisqInternalPrice=利用可能な外部価格フィードプロバイダーからの市場価格がありません。\n表示されている価格は、その通貨の最新のBisq取引価格です。
mainView.marketPrice.tooltip=市場価格は{0}{1}に提供されています\n最終更新: {2}\n提供者のノードのURL: {3}
mainView.marketPrice.tooltip.altcoinExtra=アルトコインがPoloniexで利用可能でない場合、https://coinmarketcap.com を利用します
mainView.balance.available=利用可能残高
mainView.balance.reserved=オファーのために予約済み
mainView.balance.locked=トレードにロック中
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ mainView.marketPriceWithProvider.label=Preço de mercado por {0}
mainView.marketPrice.bisqInternalPrice=Preço da última negociação Bisq
mainView.marketPrice.tooltip.bisqInternalPrice=Não foi encontrado preço de mercado nos provedores externos.\nO preço exibido corresponde ao último preço de negociação no Bisq para essa moeda.
mainView.marketPrice.tooltip=Preço de Mercado fornecido por {0}{1}\nÚltima atualização: {2}\nURL do provedor: {3}
mainView.marketPrice.tooltip.altcoinExtra=Se a altcoin não estiver disponível na Poloniex, usaremos https://coinmarketcap.com
mainView.balance.available=Saldo disponível
mainView.balance.reserved=Reservado em ofertas
mainView.balance.locked=Travado em negociações
Expand Down
1 change: 0 additions & 1 deletion core/src/main/resources/i18n/displayStrings_pt.properties
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ mainView.marketPriceWithProvider.label=Preço de mercado por {0}
mainView.marketPrice.bisqInternalPrice=Preço do último negócio do Bisq
mainView.marketPrice.tooltip.bisqInternalPrice=Não há preço de mercado de fornecedores de feed de preço externos disponíveis.\nO preço exibido é o mais recente preço de negócio do Bisq para essa moeda.
mainView.marketPrice.tooltip=O preço de mercado é fornecido por {0} {1}\nÚltima atualização: {2}\nURL do nó do provedor: {3}
mainView.marketPrice.tooltip.altcoinExtra=Se a altcoin não estiver disponível na Poloniex, usaremos https://coinmarketcap.com
mainView.balance.available=Saldo disponível
mainView.balance.reserved=Reservado em ofertas
mainView.balance.locked=Bloqueado em negócios
Expand Down
1 change: 0 additions & 1 deletion core/src/main/resources/i18n/displayStrings_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ mainView.marketPriceWithProvider.label=Рыночный курс {0}
mainView.marketPrice.bisqInternalPrice=Курс последней сделки в Bisq
mainView.marketPrice.tooltip.bisqInternalPrice=Нет данных от источника рыночного курса.\nПредоставлен курс последней сделки в Bisq для этой валютной пары.
mainView.marketPrice.tooltip=Рыночный курс предоставлен {0}{1}\nОбновление: {2}\nURL источника данных: {3}
mainView.marketPrice.tooltip.altcoinExtra=Если альткойн недоступен на Poloniex, используется https://coinmarketcap.com
mainView.balance.available=Доступный баланс
mainView.balance.reserved=Выделено на предложения
mainView.balance.locked=Используется в сделках
Expand Down
1 change: 0 additions & 1 deletion core/src/main/resources/i18n/displayStrings_th.properties
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ mainView.marketPriceWithProvider.label=ราคาตลาดโดย {0}
mainView.marketPrice.bisqInternalPrice=ราคาของการซื้อขาย Bisq ล่าสุด
mainView.marketPrice.tooltip.bisqInternalPrice=ไม่มีราคาตลาดจากผู้ให้บริการด้านราคาภายนอก\nราคาที่แสดงเป็นราคาล่าสุดของ Bisq สำหรับสกุลเงินนั้น
mainView.marketPrice.tooltip=ราคาตลาดจัดทำโดย {0} {1} \nอัปเดตล่าสุด: {2} \nnode URL ของผู้ให้บริการ: {3}
mainView.marketPrice.tooltip.altcoinExtra=หาก altcoin ไม่สามารถใช้งานได้ที่ Poloniex ทางเราใช้ https://coinmarketcap.com
mainView.balance.available=ยอดคงเหลือที่พร้อมใช้งาน
mainView.balance.reserved=ข้อเสนอได้รับการจองแล้ว
mainView.balance.locked=ล็อคในการซื้อขาย
Expand Down
1 change: 0 additions & 1 deletion core/src/main/resources/i18n/displayStrings_vi.properties
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ mainView.marketPriceWithProvider.label=Giá thị trường theo {0}
mainView.marketPrice.bisqInternalPrice=Giá giao dịch Bisq gần nhất
mainView.marketPrice.tooltip.bisqInternalPrice=Không có giá thị trường từ nhà cung cấp bên ngoài.\nGiá hiển thị là giá giao dịch Bisq gần nhất với đồng tiền này.
mainView.marketPrice.tooltip=Giá thị trường được cung cấp bởi {0}{1}\nCập nhật mới nhất: {2}\nURL nút nhà cung cấp: {3}
mainView.marketPrice.tooltip.altcoinExtra=Nếu altcoin không có trên Poloniex, sử dụng https://coinmarketcap.com
mainView.balance.available=Số dư hiện có
mainView.balance.reserved=Phần được bảo lưu trong báo giá
mainView.balance.locked=Khóa trong giao dịch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ mainView.marketPriceWithProvider.label=交易所价格提供商:{0}
mainView.marketPrice.bisqInternalPrice=最新 Bisq 交易的价格
mainView.marketPrice.tooltip.bisqInternalPrice=外部交易所供应商没有可用的市场价格。\n显示的价格是该货币的最新 Bisq 交易价格。
mainView.marketPrice.tooltip=交易所价格提供者 {0}{1}\n最后更新:{2}\n提供者节点 URL:{3}
mainView.marketPrice.tooltip.altcoinExtra=如果数字货币在 Poloniex 不可用,我们使用 https://coinmarketcap.com
mainView.balance.available=可用余额
mainView.balance.reserved=保证金
mainView.balance.locked=冻结余额
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ mainView.marketPriceWithProvider.label=交易所價格提供商:{0}
mainView.marketPrice.bisqInternalPrice=最新 Bisq 交易的價格
mainView.marketPrice.tooltip.bisqInternalPrice=外部交易所供應商沒有可用的市場價格。\n顯示的價格是該貨幣的最新 Bisq 交易價格。
mainView.marketPrice.tooltip=交易所價格提供者 {0}{1}\n最後更新:{2}\n提供者節點 URL:{3}
mainView.marketPrice.tooltip.altcoinExtra=如果數字貨幣在 Poloniex 不可用,我們使用 https://coinmarketcap.com
mainView.balance.available=可用餘額
mainView.balance.reserved=保證金
mainView.balance.locked=凍結餘額
Expand Down
24 changes: 6 additions & 18 deletions desktop/src/main/java/bisq/desktop/main/MainView.java
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ private String getPriceProvider() {
private void updateMarketPriceLabel(Label label) {
if (model.getIsPriceAvailable().get()) {
if (model.getIsExternallyProvidedPrice().get()) {
label.setText(Res.get("mainView.marketPriceWithProvider.label", getPriceProvider()));
label.setText(Res.get("mainView.marketPriceWithProvider.label", "Bisq pricenodes"));
label.setTooltip(new Tooltip(getPriceProviderTooltipString()));
} else {
label.setText(Res.get("mainView.marketPrice.bisqInternalPrice"));
Expand All @@ -527,23 +527,11 @@ private void updateMarketPriceLabel(Label label) {

@NotNull
private String getPriceProviderTooltipString() {

String res;
if (model.getIsFiatCurrencyPriceFeedSelected().get()) {
res = Res.get("mainView.marketPrice.tooltip",
"https://bitcoinaverage.com",
"",
DisplayUtils.formatTime(model.getPriceFeedService().getLastRequestTimeStampBtcAverage()),
model.getPriceFeedService().getProviderNodeAddress());
} else {
String altcoinExtra = "\n" + Res.get("mainView.marketPrice.tooltip.altcoinExtra");
res = Res.get("mainView.marketPrice.tooltip",
"https://poloniex.com",
altcoinExtra,
DisplayUtils.formatTime(model.getPriceFeedService().getLastRequestTimeStampPoloniex()),
model.getPriceFeedService().getProviderNodeAddress());
}
return res;
return Res.get("mainView.marketPrice.tooltip",
"Bisq pricenodes",
"",
DisplayUtils.formatTime(model.getPriceFeedService().getLastRequestTimeStamp()),
model.getPriceFeedService().getProviderNodeAddress());
}

private VBox createSplashScreen() {
Expand Down