Skip to content

Commit e8e2b31

Browse files
streaming is working
Signed-off-by: Matt Peterson <[email protected]>
1 parent 51ab972 commit e8e2b31

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

consumer.sh

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
11
#!/bin/bash
22

33
echo "Starting consumer..."
4-
starting_block=$1
54

6-
payload="{\"id\": $starting_block}"
5+
# Set the gRPC server address and method
6+
GRPC_SERVER="localhost:8080"
7+
GRPC_METHOD="BlockStreamGrpc/StreamSource"
78

8-
grpcurl -vv -plaintext -proto ./protos/src/main/protobuf/blockstream.proto -d "$payload" localhost:8080 BlockStreamGrpc/StreamSource
9+
# Function to handle received messages and send replies
10+
handle_streaming() {
11+
while read -r line; do
12+
id=$(echo "$line" | jq -r '.id')
13+
if [[ $id != "null" ]]; then
14+
echo "{\"id\": $id}"
15+
fi
16+
done
17+
}
918

10-
echo "Finished"
19+
# Trap SIGINT to clean up
20+
trap "echo 'Received SIGINT, stopping...'; exit 0" SIGINT
1121

22+
payload="{\"id\": 0}"
23+
24+
#grpcurl -vv -plaintext -proto ./protos/src/main/protobuf/blockstream.proto -d "$payload" localhost:8080 BlockStreamGrpc/StreamSource
25+
26+
# Initiate the bidirectional streaming connection
27+
grpcurl -vv -plaintext -proto ./protos/src/main/protobuf/blockstream.proto -d "$payload" $GRPC_SERVER $GRPC_METHOD
28+
#{} # Initial empty request if needed
29+
EOF | handle_streaming | grpcurl -plaintext -d @ $GRPC_SERVER $GRPC_METHOD --format json

server/src/main/java/com/hedera/block/server/observe/mediate/StreamMediatorImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void onNext(BlockStreamServiceGrpcProto.Block block) {
5454
}
5555

5656
// Persist the block
57-
blockPersistenceHandler.persist(block);
57+
// blockPersistenceHandler.persist(block);
5858
}
5959

6060
@Override

0 commit comments

Comments
 (0)