mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
Remove GetTradeStatistics service from grpc.proto
This protobuf definition and service stub has been in place since the start of work on the API, but was never fully implmented, nor intended to be included in the API beta & v1 releases. Its presence added a useless section to the gRPC API Reference doc. https://ghubstan.github.io/slate Based on branch `7-more-grpcproto-comments`, PR https://github.com/bisq-network/bisq/pull/6068.
This commit is contained in:
parent
c0631eb31f
commit
2e9e51eb41
@ -30,7 +30,6 @@ import bisq.core.trade.model.Tradable;
|
||||
import bisq.core.trade.model.TradeModel;
|
||||
import bisq.core.trade.model.bisq_v1.Trade;
|
||||
import bisq.core.trade.model.bsq_swap.BsqSwapTrade;
|
||||
import bisq.core.trade.statistics.TradeStatistics3;
|
||||
import bisq.core.trade.statistics.TradeStatisticsManager;
|
||||
|
||||
import bisq.common.app.Version;
|
||||
@ -47,7 +46,6 @@ import javax.inject.Singleton;
|
||||
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@ -442,10 +440,6 @@ public class CoreApi {
|
||||
walletsService.removeWalletPassword(password);
|
||||
}
|
||||
|
||||
public List<TradeStatistics3> getTradeStatistics() {
|
||||
return new ArrayList<>(tradeStatisticsManager.getObservableTradeStatisticsSet());
|
||||
}
|
||||
|
||||
public int getNumConfirmationsForMostRecentTransaction(String addressString) {
|
||||
return walletsService.getNumConfirmationsForMostRecentTransaction(addressString);
|
||||
}
|
||||
|
@ -1,72 +0,0 @@
|
||||
package bisq.daemon.grpc;
|
||||
|
||||
import bisq.core.api.CoreApi;
|
||||
import bisq.core.trade.statistics.TradeStatistics3;
|
||||
|
||||
import bisq.proto.grpc.GetTradeStatisticsReply;
|
||||
import bisq.proto.grpc.GetTradeStatisticsRequest;
|
||||
|
||||
import io.grpc.ServerInterceptor;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import static bisq.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor;
|
||||
import static bisq.proto.grpc.GetTradeStatisticsGrpc.GetTradeStatisticsImplBase;
|
||||
import static bisq.proto.grpc.GetTradeStatisticsGrpc.getGetTradeStatisticsMethod;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
|
||||
|
||||
import bisq.daemon.grpc.interceptor.CallRateMeteringInterceptor;
|
||||
import bisq.daemon.grpc.interceptor.GrpcCallRateMeter;
|
||||
|
||||
@Slf4j
|
||||
class GrpcGetTradeStatisticsService extends GetTradeStatisticsImplBase {
|
||||
|
||||
private final CoreApi coreApi;
|
||||
private final GrpcExceptionHandler exceptionHandler;
|
||||
|
||||
@Inject
|
||||
public GrpcGetTradeStatisticsService(CoreApi coreApi, GrpcExceptionHandler exceptionHandler) {
|
||||
this.coreApi = coreApi;
|
||||
this.exceptionHandler = exceptionHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTradeStatistics(GetTradeStatisticsRequest req,
|
||||
StreamObserver<GetTradeStatisticsReply> responseObserver) {
|
||||
try {
|
||||
var tradeStatistics = coreApi.getTradeStatistics().stream()
|
||||
.map(TradeStatistics3::toProtoTradeStatistics3)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
var reply = GetTradeStatisticsReply.newBuilder().addAllTradeStatistics(tradeStatistics).build();
|
||||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (Throwable cause) {
|
||||
exceptionHandler.handleException(log, cause, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
final ServerInterceptor[] interceptors() {
|
||||
Optional<ServerInterceptor> rateMeteringInterceptor = rateMeteringInterceptor();
|
||||
return rateMeteringInterceptor.map(serverInterceptor ->
|
||||
new ServerInterceptor[]{serverInterceptor}).orElseGet(() -> new ServerInterceptor[0]);
|
||||
}
|
||||
|
||||
final Optional<ServerInterceptor> rateMeteringInterceptor() {
|
||||
return getCustomRateMeteringInterceptor(coreApi.getConfig().appDataDir, this.getClass())
|
||||
.or(() -> Optional.of(CallRateMeteringInterceptor.valueOf(
|
||||
new HashMap<>() {{
|
||||
put(getGetTradeStatisticsMethod().getFullMethodName(), new GrpcCallRateMeter(1, SECONDS));
|
||||
}}
|
||||
)));
|
||||
}
|
||||
}
|
@ -56,7 +56,6 @@ public class GrpcServer {
|
||||
GrpcPriceService priceService,
|
||||
GrpcShutdownService shutdownService,
|
||||
GrpcVersionService versionService,
|
||||
GrpcGetTradeStatisticsService tradeStatisticsService,
|
||||
GrpcTradesService tradesService,
|
||||
GrpcWalletsService walletsService) {
|
||||
this.server = ServerBuilder.forPort(config.apiPort)
|
||||
@ -67,7 +66,6 @@ public class GrpcServer {
|
||||
.addService(interceptForward(paymentAccountsService, paymentAccountsService.interceptors()))
|
||||
.addService(interceptForward(priceService, priceService.interceptors()))
|
||||
.addService(shutdownService)
|
||||
.addService(interceptForward(tradeStatisticsService, tradeStatisticsService.interceptors()))
|
||||
.addService(interceptForward(tradesService, tradesService.interceptors()))
|
||||
.addService(interceptForward(versionService, versionService.interceptors()))
|
||||
.addService(interceptForward(walletsService, walletsService.interceptors()))
|
||||
|
@ -444,22 +444,6 @@ message MarketPriceReply {
|
||||
double price = 1; // The most recently available market price.
|
||||
}
|
||||
|
||||
/*
|
||||
* GetTradeStatistics service is not implemented. It's stub will be remove from the gRPC daemon.
|
||||
*/
|
||||
service GetTradeStatistics {
|
||||
// Not implemented.
|
||||
rpc GetTradeStatistics (GetTradeStatisticsRequest) returns (GetTradeStatisticsReply) {
|
||||
}
|
||||
}
|
||||
|
||||
message GetTradeStatisticsRequest {
|
||||
}
|
||||
|
||||
message GetTradeStatisticsReply {
|
||||
repeated TradeStatistics3 TradeStatistics = 1;
|
||||
}
|
||||
|
||||
service ShutdownServer {
|
||||
// Shut down a local Bisq daemon.
|
||||
rpc Stop (StopRequest) returns (StopReply) {
|
||||
@ -469,7 +453,6 @@ service ShutdownServer {
|
||||
message StopRequest {
|
||||
}
|
||||
|
||||
|
||||
message StopReply {
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user