mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
Minor refactoring
This commit is contained in:
parent
a12dd52b81
commit
2c043b4b21
@ -2,7 +2,7 @@ getavgbsqprice
|
||||
|
||||
NAME
|
||||
----
|
||||
getavgbsqprice - get average BSQ price in btc and usd
|
||||
getavgbsqprice - get average bsq price in btc and usd
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
@ -88,17 +88,7 @@ class GrpcPriceService extends PriceImplBase {
|
||||
try {
|
||||
var days = req.getDays();
|
||||
Tuple2<Price, Price> prices = coreApi.getAverageBsqTradePrice(days);
|
||||
var usdPrice = new BigDecimal(prices.first.toString())
|
||||
.setScale(Fiat.SMALLEST_UNIT_EXPONENT, RoundingMode.HALF_UP);
|
||||
var btcPrice = new BigDecimal(prices.second.toString())
|
||||
.setScale(Altcoin.SMALLEST_UNIT_EXPONENT, RoundingMode.HALF_UP);
|
||||
var proto = AverageBsqTradePrice.newBuilder()
|
||||
.setUsdPrice(usdPrice.toString())
|
||||
.setBtcPrice(btcPrice.toString())
|
||||
.build();
|
||||
var reply = GetAverageBsqTradePriceReply.newBuilder()
|
||||
.setPrice(proto)
|
||||
.build();
|
||||
var reply = buildGetAverageBsqTradePriceReply(prices);
|
||||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
@ -121,4 +111,18 @@ class GrpcPriceService extends PriceImplBase {
|
||||
}}
|
||||
)));
|
||||
}
|
||||
|
||||
private GetAverageBsqTradePriceReply buildGetAverageBsqTradePriceReply(Tuple2<Price, Price> prices) {
|
||||
var usdPrice = new BigDecimal(prices.first.toString())
|
||||
.setScale(Fiat.SMALLEST_UNIT_EXPONENT, RoundingMode.HALF_UP);
|
||||
var btcPrice = new BigDecimal(prices.second.toString())
|
||||
.setScale(Altcoin.SMALLEST_UNIT_EXPONENT, RoundingMode.HALF_UP);
|
||||
var proto = AverageBsqTradePrice.newBuilder()
|
||||
.setUsdPrice(usdPrice.toString())
|
||||
.setBtcPrice(btcPrice.toString())
|
||||
.build();
|
||||
return GetAverageBsqTradePriceReply.newBuilder()
|
||||
.setPrice(proto)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user