File tree Expand file tree Collapse file tree 4 files changed +21
-3
lines changed
server/src/main/java/com/hedera/block/server Expand file tree Collapse file tree 4 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -47,5 +47,7 @@ gradle-app.setting
47
47
# JDT-specific (Eclipse Java Development Tools)
48
48
.classpath
49
49
50
+ .idea
51
+ .DS_Store
50
52
# .env files
51
53
server /docker /.env
Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ service BlockStreamGrpc {
46
46
* message with the id of each block received.
47
47
*/
48
48
rpc StreamSource (stream BlockResponse ) returns (stream Block ) {}
49
+
50
+ rpc GetBlock (Block ) returns (Block ) {}
49
51
}
50
52
51
53
/**
Original file line number Diff line number Diff line change 27
27
28
28
import java .time .Clock ;
29
29
30
+ import static io .helidon .webserver .grpc .ResponseHelper .complete ;
31
+
30
32
import static com .hedera .block .server .Constants .*;
31
33
32
34
/**
@@ -87,6 +89,7 @@ public String serviceName() {
87
89
public void update (final Routing routing ) {
88
90
routing .bidi (CLIENT_STREAMING_METHOD_NAME , this ::streamSink );
89
91
routing .bidi (SERVER_STREAMING_METHOD_NAME , this ::streamSource );
92
+ routing .unary ("GetBlock" , this ::getBlock );
90
93
}
91
94
92
95
/**
@@ -129,6 +132,13 @@ private StreamObserver<BlockStreamServiceGrpcProto.BlockResponse> streamSource(f
129
132
130
133
return streamObserver ;
131
134
}
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
+ }
132
142
}
133
143
134
144
Original file line number Diff line number Diff line change 26
26
import io .helidon .config .Config ;
27
27
import io .helidon .webserver .WebServer ;
28
28
import io .helidon .webserver .grpc .GrpcRouting ;
29
- import io .helidon .webserver .http .HttpRouting ;
30
29
31
30
import java .io .IOException ;
32
31
import java .util .stream .Stream ;
@@ -79,13 +78,18 @@ public static void main(final String[] args) {
79
78
.bidi (BlockStreamServiceGrpcProto .getDescriptor (),
80
79
SERVICE_NAME ,
81
80
SERVER_STREAMING_METHOD_NAME ,
82
- serverBidiStreamingMethod ))
81
+ serverBidiStreamingMethod )
82
+ .unary (BlockStreamServiceGrpcProto .getDescriptor (),
83
+ "BlockStreamGrpc" ,
84
+ "GetBlock" ,
85
+ Server ::grpcGetBlock ))
83
86
.build ()
84
87
.start ();
85
-
86
88
} catch (IOException e ) {
87
89
LOGGER .log (System .Logger .Level .ERROR , "An exception was thrown starting the server" , e );
88
90
throw new RuntimeException (e );
89
91
}
90
92
}
93
+
94
+ static void grpcGetBlock (BlockStreamServiceGrpcProto .BlockRequest request , StreamObserver <BlockStreamServiceGrpcProto .Block > responseObserver ) {}
91
95
}
You can’t perform that action at this time.
0 commit comments