-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dagger, Configuration and PBJ Types
Signed-off-by: Alfredo Gutierrez <[email protected]>
- Loading branch information
1 parent
d3cdc18
commit 37a95e8
Showing
10 changed files
with
193 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ator/src/main/java/com/hedera/block/simulator/BlockStreamSimulatorInjectionComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (C) 2024 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hedera.block.simulator; | ||
|
||
import com.hedera.block.simulator.config.ConfigInjectionModule; | ||
import com.hedera.block.simulator.generator.GeneratorInjectionModule; | ||
import com.swirlds.config.api.Configuration; | ||
import dagger.BindsInstance; | ||
import dagger.Component; | ||
import javax.inject.Singleton; | ||
|
||
@Singleton | ||
@Component( | ||
modules = { | ||
ConfigInjectionModule.class, | ||
GeneratorInjectionModule.class, | ||
}) | ||
public interface BlockStreamSimulatorInjectionComponent { | ||
|
||
BlockStreamSimulator getBlockStreamSimulator(); | ||
|
||
@Component.Factory | ||
interface Factory { | ||
BlockStreamSimulatorInjectionComponent create(@BindsInstance Configuration configuration); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
simulator/src/main/java/com/hedera/block/simulator/config/ConfigInjectionModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (C) 2024 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hedera.block.simulator.config; | ||
|
||
import com.hedera.block.simulator.config.data.BlockStreamConfig; | ||
import com.hedera.block.simulator.config.data.GrpcConfig; | ||
import com.swirlds.config.api.Configuration; | ||
import dagger.Module; | ||
import dagger.Provides; | ||
import javax.inject.Singleton; | ||
|
||
@Module | ||
public interface ConfigInjectionModule { | ||
|
||
@Singleton | ||
@Provides | ||
static BlockStreamConfig provideBlockStreamConfig(Configuration configuration) { | ||
return configuration.getConfigData(BlockStreamConfig.class); | ||
} | ||
|
||
@Singleton | ||
@Provides | ||
static GrpcConfig provideGrpcConfig(Configuration configuration) { | ||
return configuration.getConfigData(GrpcConfig.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
simulator/src/main/java/com/hedera/block/simulator/generator/GeneratorInjectionModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (C) 2024 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hedera.block.simulator.generator; | ||
|
||
import dagger.Binds; | ||
import dagger.Module; | ||
import javax.inject.Singleton; | ||
|
||
@Module | ||
public interface GeneratorInjectionModule { | ||
|
||
@Singleton | ||
@Binds | ||
BlockStreamManager bindBlockStreamManager(MockBlockStreamManagerImpl blockStreamManager); | ||
} |
31 changes: 31 additions & 0 deletions
31
simulator/src/main/java/com/hedera/block/simulator/generator/MockBlockStreamManagerImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (C) 2024 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hedera.block.simulator.generator; | ||
|
||
import com.hedera.hapi.block.stream.Block; | ||
import javax.inject.Inject; | ||
|
||
public class MockBlockStreamManagerImpl implements BlockStreamManager { | ||
|
||
@Inject | ||
public MockBlockStreamManagerImpl() {} | ||
|
||
@Override | ||
public Block getNextBlock() { | ||
return Block.newBuilder().build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
blockStream.folderRootPath=/Users/user/Projects/hedera-block-node/simulator/src/main/resources/block-0.0.3/ |