diff --git a/server/src/main/java/com/hedera/block/server/BlockNodeApp.java b/server/src/main/java/com/hedera/block/server/BlockNodeApp.java index 8bbcad0a..53b0d7e0 100644 --- a/server/src/main/java/com/hedera/block/server/BlockNodeApp.java +++ b/server/src/main/java/com/hedera/block/server/BlockNodeApp.java @@ -24,6 +24,7 @@ import io.helidon.webserver.WebServer; import io.helidon.webserver.WebServerConfig; import io.helidon.webserver.grpc.GrpcRouting; +import io.helidon.webserver.grpc.GrpcService; import io.helidon.webserver.http.HttpRouting; import java.io.IOException; import javax.inject.Inject; @@ -40,7 +41,7 @@ public class BlockNodeApp { private final ServiceStatus serviceStatus; private final HealthService healthService; - private final BlockStreamService blockStreamService; + private final GrpcService blockStreamService; private final WebServerConfig.Builder webServerBuilder; /** @@ -55,7 +56,7 @@ public class BlockNodeApp { public BlockNodeApp( @NonNull ServiceStatus serviceStatus, @NonNull HealthService healthService, - @NonNull BlockStreamService blockStreamService, + @NonNull GrpcService blockStreamService, @NonNull WebServerConfig.Builder webServerBuilder) { this.serviceStatus = serviceStatus; this.healthService = healthService; diff --git a/server/src/main/java/com/hedera/block/server/BlockNodeAppInjectionModule.java b/server/src/main/java/com/hedera/block/server/BlockNodeAppInjectionModule.java index ddfa8692..023293f7 100644 --- a/server/src/main/java/com/hedera/block/server/BlockNodeAppInjectionModule.java +++ b/server/src/main/java/com/hedera/block/server/BlockNodeAppInjectionModule.java @@ -17,19 +17,13 @@ package com.hedera.block.server; import com.hedera.block.server.config.BlockNodeContext; -import com.hedera.block.server.data.ObjectEvent; -import com.hedera.block.server.mediator.StreamMediator; import com.hedera.block.server.metrics.MetricsService; -import com.hedera.block.server.persistence.storage.read.BlockReader; -import com.hedera.hapi.block.SubscribeStreamResponse; -import com.hedera.hapi.block.stream.Block; -import com.hedera.hapi.block.stream.BlockItem; import com.swirlds.config.api.Configuration; import dagger.Binds; import dagger.Module; import dagger.Provides; -import edu.umd.cs.findbugs.annotations.NonNull; import io.helidon.webserver.WebServerConfig; +import io.helidon.webserver.grpc.GrpcService; import javax.inject.Singleton; /** @@ -66,23 +60,12 @@ static BlockNodeContext provideBlockNodeContext( /** * Provides a block stream service singleton using DI. * - * @param streamMediator should come from DI - * @param blockReader should come from DI - * @param serviceStatus should come from DI - * @param blockNodeContext should come from DI + * @param blockStreamService should come from DI * @return a block stream service singleton */ @Singleton - @Provides - static BlockStreamService provideBlockStreamService( - @NonNull - final StreamMediator> - streamMediator, - @NonNull final BlockReader blockReader, - @NonNull final ServiceStatus serviceStatus, - @NonNull final BlockNodeContext blockNodeContext) { - return new BlockStreamService(streamMediator, blockReader, serviceStatus, blockNodeContext); - } + @Binds + GrpcService bindBlockStreamService(BlockStreamService blockStreamService); /** * Provides a web server config builder singleton using DI. diff --git a/server/src/main/java/com/hedera/block/server/config/ConfigInjectionModule.java b/server/src/main/java/com/hedera/block/server/config/ConfigInjectionModule.java index db15f894..94365187 100644 --- a/server/src/main/java/com/hedera/block/server/config/ConfigInjectionModule.java +++ b/server/src/main/java/com/hedera/block/server/config/ConfigInjectionModule.java @@ -23,7 +23,6 @@ import com.swirlds.config.api.Configuration; import dagger.Module; import dagger.Provides; -import edu.umd.cs.findbugs.annotations.NonNull; import javax.inject.Singleton; /** @@ -41,8 +40,7 @@ public interface ConfigInjectionModule { */ @Singleton @Provides - static PersistenceStorageConfig providePersistenceStorageConfig( - @NonNull Configuration configuration) { + static PersistenceStorageConfig providePersistenceStorageConfig(Configuration configuration) { return configuration.getConfigData(PersistenceStorageConfig.class); } @@ -54,7 +52,7 @@ static PersistenceStorageConfig providePersistenceStorageConfig( */ @Singleton @Provides - static MetricsConfig provideMetricsConfig(@NonNull Configuration configuration) { + static MetricsConfig provideMetricsConfig(Configuration configuration) { return configuration.getConfigData(MetricsConfig.class); } @@ -66,7 +64,7 @@ static MetricsConfig provideMetricsConfig(@NonNull Configuration configuration) */ @Singleton @Provides - static PrometheusConfig providePrometheusConfig(@NonNull Configuration configuration) { + static PrometheusConfig providePrometheusConfig(Configuration configuration) { return configuration.getConfigData(PrometheusConfig.class); } @@ -78,7 +76,7 @@ static PrometheusConfig providePrometheusConfig(@NonNull Configuration configura */ @Singleton @Provides - static ConsumerConfig provideConsumerConfig(@NonNull Configuration configuration) { + static ConsumerConfig provideConsumerConfig(Configuration configuration) { return configuration.getConfigData(ConsumerConfig.class); } } diff --git a/server/src/main/java/com/hedera/block/server/health/HealthInjectionModule.java b/server/src/main/java/com/hedera/block/server/health/HealthInjectionModule.java index db882c9b..377cbc53 100644 --- a/server/src/main/java/com/hedera/block/server/health/HealthInjectionModule.java +++ b/server/src/main/java/com/hedera/block/server/health/HealthInjectionModule.java @@ -18,7 +18,6 @@ import dagger.Binds; import dagger.Module; -import edu.umd.cs.findbugs.annotations.NonNull; import javax.inject.Singleton; /** @@ -36,5 +35,5 @@ public interface HealthInjectionModule { */ @Singleton @Binds - HealthService bindHealthService(@NonNull HealthServiceImpl healthService); + HealthService bindHealthService(HealthServiceImpl healthService); } diff --git a/server/src/main/java/com/hedera/block/server/persistence/PersistenceInjectionModule.java b/server/src/main/java/com/hedera/block/server/persistence/PersistenceInjectionModule.java index e9337b18..2cddc12b 100644 --- a/server/src/main/java/com/hedera/block/server/persistence/PersistenceInjectionModule.java +++ b/server/src/main/java/com/hedera/block/server/persistence/PersistenceInjectionModule.java @@ -26,7 +26,6 @@ import com.hedera.hapi.block.stream.BlockItem; import dagger.Module; import dagger.Provides; -import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; import javax.inject.Singleton; @@ -42,7 +41,7 @@ public interface PersistenceInjectionModule { */ @Provides @Singleton - static BlockWriter providesBlockWriter(@NonNull BlockNodeContext blockNodeContext) { + static BlockWriter providesBlockWriter(BlockNodeContext blockNodeContext) { try { return BlockAsDirWriterBuilder.newBuilder(blockNodeContext).build(); } catch (IOException e) { @@ -58,7 +57,7 @@ static BlockWriter providesBlockWriter(@NonNull BlockNodeContext bloc */ @Provides @Singleton - static BlockReader providesBlockReader(@NonNull PersistenceStorageConfig config) { + static BlockReader providesBlockReader(PersistenceStorageConfig config) { return BlockAsDirReaderBuilder.newBuilder(config).build(); } } diff --git a/server/src/test/java/com/hedera/block/server/BlockNodeAppInjectionModuleTest.java b/server/src/test/java/com/hedera/block/server/BlockNodeAppInjectionModuleTest.java index 831fa88e..cfafca95 100644 --- a/server/src/test/java/com/hedera/block/server/BlockNodeAppInjectionModuleTest.java +++ b/server/src/test/java/com/hedera/block/server/BlockNodeAppInjectionModuleTest.java @@ -63,15 +63,6 @@ void testProvideBlockNodeContext() { blockNodeContext.metricsService(), providedBlockNodeContext.metricsService()); } - @Test - void testProvideBlockStreamService() { - BlockStreamService blockStreamService = - BlockNodeAppInjectionModule.provideBlockStreamService( - streamMediator, blockReader, serviceStatus, blockNodeContext); - - Assertions.assertNotNull(blockStreamService); - } - @Test void testProvideWebServerConfigBuilder() { WebServerConfig.Builder webServerConfigBuilder =