mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Remove unused dependency on Pricenode metadata strings.
This commit is contained in:
parent
d4dc950992
commit
9600d79584
3 changed files with 10 additions and 20 deletions
|
@ -394,21 +394,17 @@ public class PriceFeedService {
|
||||||
}
|
}
|
||||||
|
|
||||||
priceRequest = new PriceRequest();
|
priceRequest = new PriceRequest();
|
||||||
SettableFuture<Tuple2<Map<String, Long>, Map<String, MarketPrice>>> future = priceRequest.requestAllPrices(provider);
|
SettableFuture<Map<String, MarketPrice>> future = priceRequest.requestAllPrices(provider);
|
||||||
Futures.addCallback(future, new FutureCallback<>() {
|
Futures.addCallback(future, new FutureCallback<>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(@Nullable Tuple2<Map<String, Long>, Map<String, MarketPrice>> result) {
|
public void onSuccess(@Nullable Map<String, MarketPrice> result) {
|
||||||
UserThread.execute(() -> {
|
UserThread.execute(() -> {
|
||||||
checkNotNull(result, "Result must not be null at requestAllPrices");
|
checkNotNull(result, "Result must not be null at requestAllPrices");
|
||||||
// Each currency rate has a different timestamp, depending on when
|
// Each currency rate has a different timestamp, depending on when
|
||||||
// the priceNode aggregate rate was calculated
|
// the priceNode aggregate rate was calculated
|
||||||
// However, the request timestamp is when the pricenode was queried
|
// However, the request timestamp is when the pricenode was queried
|
||||||
epochInMillisAtLastRequest = System.currentTimeMillis();
|
epochInMillisAtLastRequest = System.currentTimeMillis();
|
||||||
|
cache.putAll(result);
|
||||||
Map<String, MarketPrice> priceMap = result.second;
|
|
||||||
|
|
||||||
cache.putAll(priceMap);
|
|
||||||
|
|
||||||
resultHandler.run();
|
resultHandler.run();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,9 +48,9 @@ public class PriceProvider extends HttpClientProvider {
|
||||||
super(httpClient, baseUrl, false);
|
super(httpClient, baseUrl, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tuple2<Map<String, Long>, Map<String, MarketPrice>> getAll() throws IOException {
|
public Map<String, MarketPrice> getAll() throws IOException {
|
||||||
if (shutDownRequested) {
|
if (shutDownRequested) {
|
||||||
return new Tuple2<>(new HashMap<>(), new HashMap<>());
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, MarketPrice> marketPriceMap = new HashMap<>();
|
Map<String, MarketPrice> marketPriceMap = new HashMap<>();
|
||||||
|
@ -61,13 +61,7 @@ public class PriceProvider extends HttpClientProvider {
|
||||||
String json = httpClient.get("getAllMarketPrices", "User-Agent", "bisq/"
|
String json = httpClient.get("getAllMarketPrices", "User-Agent", "bisq/"
|
||||||
+ Version.VERSION + hsVersion);
|
+ Version.VERSION + hsVersion);
|
||||||
|
|
||||||
|
|
||||||
LinkedTreeMap<?, ?> map = new Gson().fromJson(json, LinkedTreeMap.class);
|
LinkedTreeMap<?, ?> map = new Gson().fromJson(json, LinkedTreeMap.class);
|
||||||
Map<String, Long> tsMap = new HashMap<>();
|
|
||||||
tsMap.put("btcAverageTs", ((Double) map.get("btcAverageTs")).longValue());
|
|
||||||
tsMap.put("poloniexTs", ((Double) map.get("poloniexTs")).longValue());
|
|
||||||
tsMap.put("coinmarketcapTs", ((Double) map.get("coinmarketcapTs")).longValue());
|
|
||||||
|
|
||||||
List<?> list = (ArrayList<?>) map.get("data");
|
List<?> list = (ArrayList<?>) map.get("data");
|
||||||
list.forEach(obj -> {
|
list.forEach(obj -> {
|
||||||
try {
|
try {
|
||||||
|
@ -83,7 +77,7 @@ public class PriceProvider extends HttpClientProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
return new Tuple2<>(tsMap, marketPriceMap);
|
return marketPriceMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBaseUrl() {
|
public String getBaseUrl() {
|
||||||
|
|
|
@ -45,17 +45,17 @@ public class PriceRequest {
|
||||||
public PriceRequest() {
|
public PriceRequest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SettableFuture<Tuple2<Map<String, Long>, Map<String, MarketPrice>>> requestAllPrices(PriceProvider provider) {
|
public SettableFuture<Map<String, MarketPrice>> requestAllPrices(PriceProvider provider) {
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
String baseUrl = provider.getBaseUrl();
|
String baseUrl = provider.getBaseUrl();
|
||||||
SettableFuture<Tuple2<Map<String, Long>, Map<String, MarketPrice>>> resultFuture = SettableFuture.create();
|
SettableFuture<Map<String, MarketPrice>> resultFuture = SettableFuture.create();
|
||||||
ListenableFuture<Tuple2<Map<String, Long>, Map<String, MarketPrice>>> future = executorService.submit(() -> {
|
ListenableFuture<Map<String, MarketPrice>> future = executorService.submit(() -> {
|
||||||
Thread.currentThread().setName(Thread.currentThread().getName() + "@" + baseUrl);
|
Thread.currentThread().setName(Thread.currentThread().getName() + "@" + baseUrl);
|
||||||
return provider.getAll();
|
return provider.getAll();
|
||||||
});
|
});
|
||||||
|
|
||||||
Futures.addCallback(future, new FutureCallback<>() {
|
Futures.addCallback(future, new FutureCallback<>() {
|
||||||
public void onSuccess(Tuple2<Map<String, Long>, Map<String, MarketPrice>> marketPriceTuple) {
|
public void onSuccess(Map<String, MarketPrice> marketPriceTuple) {
|
||||||
log.trace("Received marketPriceTuple of {}\nfrom provider {}", marketPriceTuple, provider);
|
log.trace("Received marketPriceTuple of {}\nfrom provider {}", marketPriceTuple, provider);
|
||||||
if (!shutDownRequested) {
|
if (!shutDownRequested) {
|
||||||
resultFuture.set(marketPriceTuple);
|
resultFuture.set(marketPriceTuple);
|
||||||
|
|
Loading…
Add table
Reference in a new issue