|
16 | 16 |
|
17 | 17 | package com.hedera.block.server.producer;
|
18 | 18 |
|
| 19 | +import static com.hedera.block.protos.BlockStreamService.*; |
| 20 | + |
19 | 21 | import com.google.protobuf.ByteString;
|
20 | 22 | import com.hedera.block.server.data.ObjectEvent;
|
21 | 23 | import com.hedera.block.server.mediator.StreamMediator;
|
22 | 24 | import io.grpc.stub.StreamObserver;
|
23 |
| - |
24 | 25 | import java.io.ByteArrayOutputStream;
|
25 | 26 | import java.io.IOException;
|
26 | 27 | import java.io.ObjectOutputStream;
|
27 | 28 | import java.security.MessageDigest;
|
28 | 29 | import java.security.NoSuchAlgorithmException;
|
29 | 30 |
|
30 |
| -import static com.hedera.block.protos.BlockStreamService.*; |
31 |
| - |
32 | 31 | /**
|
33 | 32 | * The ProducerBlockStreamObserver class plugs into Helidon's server-initiated bidirectional gRPC
|
34 | 33 | * service implementation. Helidon calls methods on this class as networking events occur with the
|
@@ -72,9 +71,7 @@ public void onNext(final PublishStreamRequest publishStreamRequest) {
|
72 | 71 | .setItemAck(ByteString.copyFrom(getFakeHash(blockItem)))
|
73 | 72 | .build();
|
74 | 73 | final PublishStreamResponse publishStreamResponse =
|
75 |
| - PublishStreamResponse.newBuilder() |
76 |
| - .setAcknowledgement(itemAck) |
77 |
| - .build(); |
| 74 | + PublishStreamResponse.newBuilder().setAcknowledgement(itemAck).build(); |
78 | 75 | publishStreamResponseObserver.onNext(publishStreamResponse);
|
79 | 76 | } catch (IOException | NoSuchAlgorithmException e) {
|
80 | 77 | LOGGER.log(System.Logger.Level.ERROR, "Error calculating hash", e);
|
@@ -103,9 +100,11 @@ public void onCompleted() {
|
103 | 100 | publishStreamResponseObserver.onCompleted();
|
104 | 101 | }
|
105 | 102 |
|
106 |
| - private static byte[] getFakeHash(BlockItem blockItem) throws IOException, NoSuchAlgorithmException { |
| 103 | + private static byte[] getFakeHash(BlockItem blockItem) |
| 104 | + throws IOException, NoSuchAlgorithmException { |
107 | 105 | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
108 |
| - try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream)) { |
| 106 | + try (ObjectOutputStream objectOutputStream = |
| 107 | + new ObjectOutputStream(byteArrayOutputStream)) { |
109 | 108 | objectOutputStream.writeObject(blockItem);
|
110 | 109 | }
|
111 | 110 |
|
|
0 commit comments