mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-03 04:06:23 -04:00
Add market depth info API call (#190)
This commit is contained in:
parent
e3b9a9962b
commit
5b038697c3
9 changed files with 187 additions and 5 deletions
|
@ -195,7 +195,7 @@ class GrpcOffersService extends OffersImplBase {
|
|||
put(getGetMyOfferMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
||||
put(getGetOffersMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
||||
put(getGetMyOffersMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
||||
put(getCreateOfferMethod().getFullMethodName(), new GrpcCallRateMeter(1, SECONDS));
|
||||
put(getCreateOfferMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
||||
put(getCancelOfferMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
||||
}}
|
||||
)));
|
||||
|
|
|
@ -174,7 +174,7 @@ class GrpcPaymentAccountsService extends PaymentAccountsImplBase {
|
|||
.or(() -> Optional.of(CallRateMeteringInterceptor.valueOf(
|
||||
new HashMap<>() {{
|
||||
put(getCreatePaymentAccountMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
||||
put(getCreateCryptoCurrencyPaymentAccountMethod().getFullMethodName(), new GrpcCallRateMeter(1, SECONDS));
|
||||
put(getCreateCryptoCurrencyPaymentAccountMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
||||
put(getGetPaymentAccountsMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
||||
put(getGetPaymentMethodsMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
||||
put(getGetPaymentAccountFormMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
||||
|
|
|
@ -18,8 +18,10 @@
|
|||
package bisq.daemon.grpc;
|
||||
|
||||
import bisq.core.api.CoreApi;
|
||||
import bisq.core.api.model.MarketDepthInfo;
|
||||
import bisq.core.api.model.MarketPriceInfo;
|
||||
|
||||
import bisq.proto.grpc.MarketDepthReply;
|
||||
import bisq.proto.grpc.MarketDepthRequest;
|
||||
import bisq.proto.grpc.MarketPriceReply;
|
||||
import bisq.proto.grpc.MarketPriceRequest;
|
||||
import bisq.proto.grpc.MarketPricesReply;
|
||||
|
@ -81,6 +83,17 @@ class GrpcPriceService extends PriceImplBase {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMarketDepth(MarketDepthRequest req,
|
||||
StreamObserver<MarketDepthReply> responseObserver) {
|
||||
try {
|
||||
responseObserver.onNext(mapMarketDepthReply(coreApi.getMarketDepth(req.getCurrencyCode())));
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
private MarketPricesReply mapMarketPricesReply(List<MarketPriceInfo> marketPrices) {
|
||||
MarketPricesReply.Builder builder = MarketPricesReply.newBuilder();
|
||||
marketPrices.stream()
|
||||
|
@ -89,6 +102,10 @@ class GrpcPriceService extends PriceImplBase {
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
private MarketDepthReply mapMarketDepthReply(MarketDepthInfo marketDepth) {
|
||||
return MarketDepthReply.newBuilder().setMarketDepth(marketDepth.toProtoMessage()).build();
|
||||
}
|
||||
|
||||
final ServerInterceptor[] interceptors() {
|
||||
Optional<ServerInterceptor> rateMeteringInterceptor = rateMeteringInterceptor();
|
||||
return rateMeteringInterceptor.map(serverInterceptor ->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue