Skip to content

Commit

Permalink
fix: removed commented out code (#100)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Peterson <[email protected]>
  • Loading branch information
mattp-swirldslabs authored Aug 13, 2024
1 parent c6fb100 commit 87a1ac3
Showing 1 changed file with 0 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,100 +158,6 @@ void subscribeBlockStream(
}
}

/*
public static class SingleBlockUnaryMethod implements GrpcService.Routing.UnaryMethod<SingleBlockRequest, SingleBlockResponse> {
// implements ServerCalls.UnaryMethod<
// SingleBlockRequest, StreamObserver<SingleBlockResponse>> {
private final System.Logger LOGGER = System.getLogger(getClass().getName());
private final BlockReader<Block> blockReader;
private final ServiceStatus serviceStatus;
private final BlockNodeContext blockNodeContext;
private SingleBlockUnaryMethod(@NonNull final BlockReader<Block> 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<StreamObserver<SingleBlockResponse>> singleBlockResponseStreamObserver) {
LOGGER.log(System.Logger.Level.DEBUG, "Executing Unary singleBlock gRPC method");
if (serviceStatus.isRunning()) {
final long blockNumber = singleBlockRequest.getBlockNumber();
try {
@NonNull final Optional<Block> 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<SingleBlockResponse> buildSingleBlockNotAvailableResponse() {
return SingleBlockResponse.newBuilder()
.setStatus(SingleBlockResponse.SingleBlockResponseCode.READ_BLOCK_NOT_AVAILABLE)
.build();
}
@NonNull
static StreamObserver<SingleBlockResponse> buildSingleBlockNotFoundResponse() {
return SingleBlockResponse.newBuilder()
.setStatus(SingleBlockResponse.SingleBlockResponseCode.READ_BLOCK_NOT_FOUND)
.build();
}
@NonNull
private static StreamObserver<SingleBlockResponse> buildSingleBlockResponse(@NonNull final Block block) {
return SingleBlockResponse.newBuilder().setBlock(block).build();
}
}
*/

void singleBlock(
@NonNull final SingleBlockRequest singleBlockRequest,
@NonNull final StreamObserver<SingleBlockResponse> singleBlockResponseStreamObserver) {
Expand Down

0 comments on commit 87a1ac3

Please sign in to comment.