Skip to content

Commit

Permalink
first set of PR review comments addressed
Browse files Browse the repository at this point in the history
Signed-off-by: Alfredo Gutierrez <[email protected]>
  • Loading branch information
AlfredoG87 committed Aug 22, 2024
1 parent 5387c34 commit a65dbea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,6 @@ extraJavaModuleInfo {
)
module("com.google.errorprone:javac-shaded", "com.google.errorprone.javac.shaded")
module("com.google.googlejavaformat:google-java-format", "com.google.googlejavaformat")
module("net.ltgt.gradle.incap:incap", "net.ltgt.gradle.incap")
// module("net.ltgt.gradle.incap:incap", "net.ltgt.gradle.incap")
module("org.jetbrains.kotlinx:kotlinx-metadata-jvm", "kotlinx.metadata.jvm")
}
43 changes: 15 additions & 28 deletions server/src/main/java/com/hedera/block/server/BlockNodeApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

package com.hedera.block.server;

import com.hedera.block.protos.BlockStreamService.Block;
import com.hedera.block.protos.BlockStreamService.BlockItem;
import com.hedera.block.protos.BlockStreamService.SubscribeStreamResponse;
import com.hedera.block.server.config.BlockNodeContext;
import com.hedera.block.server.data.ObjectEvent;
import com.hedera.block.server.health.HealthService;
Expand All @@ -35,14 +38,15 @@
import javax.inject.Inject;
import javax.inject.Singleton;


/**
* The main class for the Block Node application. This class is responsible for starting the server
* and initializing the context.
*/
@Singleton
public class BlockNodeApp {

private static final System.Logger LOGGER = System.getLogger(Server.class.getName());
private static final System.Logger LOGGER = System.getLogger(BlockNodeApp.class.getName());
private final ServiceStatus serviceStatus;
private final HealthService healthService;
private final BlockNodeContext blockNodeContext;
Expand All @@ -69,43 +73,30 @@ public BlockNodeApp(
* @throws IOException if the server cannot be started
*/
public void startServer() throws IOException {

@NonNull
final BlockWriter<com.hedera.block.protos.BlockStreamService.BlockItem> blockWriter =
final BlockWriter<BlockItem> blockWriter =
BlockAsDirWriterBuilder.newBuilder(blockNodeContext).build();
@NonNull
final StreamMediator<
com.hedera.block.protos.BlockStreamService.BlockItem,
ObjectEvent<
com.hedera.block.protos.BlockStreamService.SubscribeStreamResponse>>
streamMediator =
LiveStreamMediatorBuilder.newBuilder(
blockWriter, blockNodeContext, serviceStatus)
.build();

@NonNull
final BlockReader<com.hedera.block.protos.BlockStreamService.Block> blockReader =
final StreamMediator<BlockItem, ObjectEvent<SubscribeStreamResponse>> streamMediator =
LiveStreamMediatorBuilder.newBuilder(blockWriter, blockNodeContext, serviceStatus)
.build();

final BlockReader<Block> blockReader =
BlockAsDirReaderBuilder.newBuilder(
blockNodeContext
.configuration()
.getConfigData(PersistenceStorageConfig.class))
.build();

@NonNull
final BlockStreamService blockStreamService =
buildBlockStreamService(
streamMediator, blockReader, serviceStatus, blockNodeContext);

@NonNull
final GrpcRouting.Builder grpcRouting = GrpcRouting.builder().service(blockStreamService);

@NonNull
final HttpRouting.Builder httpRouting =
HttpRouting.builder().register(healthService.getHealthRootPath(), healthService);

// Build the web server
// TODO: make port server a configurable value.
@NonNull
final WebServer webServer =
WebServer.builder()
.port(8080)
Expand All @@ -121,20 +112,16 @@ public void startServer() throws IOException {

// Log the server status
LOGGER.log(
System.Logger.Level.INFO, "Block Node Server started at port: " + webServer.port());
System.Logger.Level.INFO,
String.format("Block Node Server started at port: %d", webServer.port()));
}

@NonNull
private static BlockStreamService buildBlockStreamService(
@NonNull
final StreamMediator<
com.hedera.block.protos.BlockStreamService.BlockItem,
ObjectEvent<
com.hedera.block.protos.BlockStreamService
.SubscribeStreamResponse>>
final StreamMediator<BlockItem, ObjectEvent<SubscribeStreamResponse>>
streamMediator,
@NonNull
final BlockReader<com.hedera.block.protos.BlockStreamService.Block> blockReader,
@NonNull final BlockReader<Block> blockReader,
@NonNull final ServiceStatus serviceStatus,
@NonNull final BlockNodeContext blockNodeContext) {

Expand Down

0 comments on commit a65dbea

Please sign in to comment.