Skip to content

Commit ef9e16d

Browse files
committed
Collapsing 3 commits together.
Signed-off-by: a-saksena <[email protected]>
1 parent e39f64d commit ef9e16d

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,7 @@ gradle-app.setting
4747
# JDT-specific (Eclipse Java Development Tools)
4848
.classpath
4949

50+
.idea
51+
.DS_Store
5052
# .env files
5153
server/docker/.env

protos/src/main/protobuf/blockstream.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ service BlockStreamGrpc {
4646
* message with the id of each block received.
4747
*/
4848
rpc StreamSource(stream BlockResponse) returns (stream Block) {}
49+
50+
rpc GetBlock(Block) returns (Block) {}
4951
}
5052

5153
/**

server/src/main/java/com/hedera/block/server/BlockStreamService.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
import java.time.Clock;
2929

30+
import static io.helidon.webserver.grpc.ResponseHelper.complete;
31+
3032
import static com.hedera.block.server.Constants.*;
3133

3234
/**
@@ -87,6 +89,7 @@ public String serviceName() {
8789
public void update(final Routing routing) {
8890
routing.bidi(CLIENT_STREAMING_METHOD_NAME, this::streamSink);
8991
routing.bidi(SERVER_STREAMING_METHOD_NAME, this::streamSource);
92+
routing.unary("GetBlock", this::getBlock);
9093
}
9194

9295
/**
@@ -129,6 +132,13 @@ private StreamObserver<BlockStreamServiceGrpcProto.BlockResponse> streamSource(f
129132

130133
return streamObserver;
131134
}
135+
136+
private void getBlock(BlockStreamServiceGrpcProto.BlockRequest request, StreamObserver<BlockStreamServiceGrpcProto.Block> responseObserver) {
137+
String message = "GET BLOCK RESPONSE! ";
138+
LOGGER.log(System.Logger.Level.INFO, "GetBlock request received");
139+
BlockStreamServiceGrpcProto.Block response = BlockStreamServiceGrpcProto.Block.newBuilder().setValue(message).build();
140+
complete(responseObserver, response);
141+
}
132142
}
133143

134144

server/src/main/java/com/hedera/block/server/Server.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import io.helidon.config.Config;
2727
import io.helidon.webserver.WebServer;
2828
import io.helidon.webserver.grpc.GrpcRouting;
29-
import io.helidon.webserver.http.HttpRouting;
3029

3130
import java.io.IOException;
3231
import java.util.stream.Stream;
@@ -79,13 +78,18 @@ public static void main(final String[] args) {
7978
.bidi(BlockStreamServiceGrpcProto.getDescriptor(),
8079
SERVICE_NAME,
8180
SERVER_STREAMING_METHOD_NAME,
82-
serverBidiStreamingMethod))
81+
serverBidiStreamingMethod)
82+
.unary(BlockStreamServiceGrpcProto.getDescriptor(),
83+
"BlockStreamGrpc",
84+
"GetBlock",
85+
Server::grpcGetBlock))
8386
.build()
8487
.start();
85-
8688
} catch (IOException e) {
8789
LOGGER.log(System.Logger.Level.ERROR, "An exception was thrown starting the server", e);
8890
throw new RuntimeException(e);
8991
}
9092
}
93+
94+
static void grpcGetBlock(BlockStreamServiceGrpcProto.BlockRequest request, StreamObserver<BlockStreamServiceGrpcProto.Block> responseObserver) {}
9195
}

0 commit comments

Comments
 (0)