Add market depth info API call (#190)

This commit is contained in:
Randall B 2022-02-11 17:13:41 -06:00 committed by GitHub
parent e3b9a9962b
commit 5b038697c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 187 additions and 5 deletions

View file

@ -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));
}}
)));

View file

@ -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));

View file

@ -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 ->