From 87a1ac34f95493dcec6377717817ac1f82e94674 Mon Sep 17 00:00:00 2001 From: Matt Peterson Date: Tue, 13 Aug 2024 17:42:11 -0600 Subject: [PATCH] fix: removed commented out code (#100) Signed-off-by: Matt Peterson --- .../block/server/BlockStreamService.java | 94 ------------------- 1 file changed, 94 deletions(-) diff --git a/server/src/main/java/com/hedera/block/server/BlockStreamService.java b/server/src/main/java/com/hedera/block/server/BlockStreamService.java index 77fb3b3e0..5b0f1d80d 100644 --- a/server/src/main/java/com/hedera/block/server/BlockStreamService.java +++ b/server/src/main/java/com/hedera/block/server/BlockStreamService.java @@ -158,100 +158,6 @@ void subscribeBlockStream( } } - /* - public static class SingleBlockUnaryMethod implements GrpcService.Routing.UnaryMethod { - // implements ServerCalls.UnaryMethod< - // SingleBlockRequest, StreamObserver> { - - private final System.Logger LOGGER = System.getLogger(getClass().getName()); - - private final BlockReader blockReader; - private final ServiceStatus serviceStatus; - private final BlockNodeContext blockNodeContext; - - private SingleBlockUnaryMethod(@NonNull final BlockReader blockReader, - @NonNull final ServiceStatus serviceStatus, - @NonNull final BlockNodeContext blockNodeContext) { - this.blockReader = blockReader; - this.serviceStatus = serviceStatus; - this.blockNodeContext = blockNodeContext; - } - - @Override - public void afterClose() { - LOGGER.log(System.Logger.Level.DEBUG, "Unary singleBlock gRPC method closed"); - } - - @Override - public void invoke( - SingleBlockRequest singleBlockRequest, - StreamObserver> singleBlockResponseStreamObserver) { - - LOGGER.log(System.Logger.Level.DEBUG, "Executing Unary singleBlock gRPC method"); - - if (serviceStatus.isRunning()) { - final long blockNumber = singleBlockRequest.getBlockNumber(); - try { - @NonNull final Optional blockOpt = blockReader.read(blockNumber); - if (blockOpt.isPresent()) { - LOGGER.log( - System.Logger.Level.DEBUG, - "Successfully returning block number: {0}", - blockNumber); - singleBlockResponseStreamObserver.onNext( - buildSingleBlockResponse(blockOpt.get())); - - @NonNull - final MetricsService metricsService = blockNodeContext.metricsService(); - metricsService.singleBlockRetrievedCounter.increment(); - } else { - LOGGER.log( - System.Logger.Level.DEBUG, - "Block number {0} not found", - blockNumber); - singleBlockResponseStreamObserver.onNext( - buildSingleBlockNotFoundResponse()); - } - } catch (IOException e) { - LOGGER.log( - System.Logger.Level.ERROR, - "Error reading block number: {0}", - blockNumber); - singleBlockResponseStreamObserver.onNext( - buildSingleBlockNotAvailableResponse()); - } - } else { - LOGGER.log( - System.Logger.Level.ERROR, - "Unary singleBlock gRPC method is not currently running"); - singleBlockResponseStreamObserver.onNext(buildSingleBlockNotAvailableResponse()); - } - - // Send the response - singleBlockResponseStreamObserver.onCompleted(); - } - - @NonNull - static StreamObserver buildSingleBlockNotAvailableResponse() { - return SingleBlockResponse.newBuilder() - .setStatus(SingleBlockResponse.SingleBlockResponseCode.READ_BLOCK_NOT_AVAILABLE) - .build(); - } - - @NonNull - static StreamObserver buildSingleBlockNotFoundResponse() { - return SingleBlockResponse.newBuilder() - .setStatus(SingleBlockResponse.SingleBlockResponseCode.READ_BLOCK_NOT_FOUND) - .build(); - } - - @NonNull - private static StreamObserver buildSingleBlockResponse(@NonNull final Block block) { - return SingleBlockResponse.newBuilder().setBlock(block).build(); - } - } - */ - void singleBlock( @NonNull final SingleBlockRequest singleBlockRequest, @NonNull final StreamObserver singleBlockResponseStreamObserver) {