Skip to content

Commit

Permalink
rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed May 8, 2022
1 parent 5dbb6e3 commit a7dd162
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public class PowchainService extends Service {
public PowchainService(
final ServiceConfig serviceConfig,
final PowchainConfiguration powConfig,
final Optional<ExecutionWeb3jClientProvider> maybeExecutionClientProvider) {
checkArgument(powConfig.isEnabled() || maybeExecutionClientProvider.isPresent());
final Optional<ExecutionWeb3jClientProvider> maybeExecutionWeb3jClientProvider) {
checkArgument(powConfig.isEnabled() || maybeExecutionWeb3jClientProvider.isPresent());

AsyncRunner asyncRunner = serviceConfig.createAsyncRunner("powchain");

Expand All @@ -82,14 +82,14 @@ public PowchainService(
if (!powConfig.isEnabled()) {
LOG.info("Eth1 endpoint not provided, using execution engine endpoint for eth1 data");
this.web3js =
Collections.singletonList(maybeExecutionClientProvider.orElseThrow().getWeb3j());
Collections.singletonList(maybeExecutionWeb3jClientProvider.orElseThrow().getWeb3j());
eth1ProviderSelector =
new Eth1ProviderSelector(
Collections.singletonList(
new Web3jEth1Provider(
powConfig.getSpec().getGenesisSpecConfig(),
serviceConfig.getMetricsSystem(),
maybeExecutionClientProvider.get().getEndpoint(),
maybeExecutionWeb3jClientProvider.get().getEndpoint(),
web3js.get(0),
asyncRunner,
serviceConfig.getTimeProvider())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,36 @@ public BeaconNodeServiceController(
TekuConfiguration tekuConfig, final ServiceConfig serviceConfig) {
// Note services will be started in the order they are added here.
services.add(new StorageService(serviceConfig, tekuConfig.storageConfiguration()));
Optional<ExecutionWeb3jClientProvider> maybeExecutionClientProvider = Optional.empty();
Optional<ExecutionWeb3jClientProvider> maybeExecutionWeb3jClientProvider = Optional.empty();
if (tekuConfig.executionLayer().isEnabled()) {
// Need to make sure the execution engine is listening before starting the beacon chain
ExecutionLayerService executionLayerService =
new ExecutionLayerService(serviceConfig, tekuConfig.executionLayer());
services.add(executionLayerService);
maybeExecutionClientProvider = executionLayerService.getEngineWeb3jClientProvider();
maybeExecutionWeb3jClientProvider = executionLayerService.getEngineWeb3jClientProvider();
}
services.add(new BeaconChainService(serviceConfig, tekuConfig.beaconChain()));
services.add(
new NatService(
tekuConfig.natConfiguration(),
tekuConfig.network().getListenPort(),
tekuConfig.discovery().isDiscoveryEnabled()));
powchainService(tekuConfig, serviceConfig, maybeExecutionClientProvider)
powchainService(tekuConfig, serviceConfig, maybeExecutionWeb3jClientProvider)
.ifPresent(services::add);
services.add(ValidatorClientService.create(serviceConfig, tekuConfig.validatorClient()));
}

private Optional<PowchainService> powchainService(
final TekuConfiguration tekuConfig,
final ServiceConfig serviceConfig,
final Optional<ExecutionWeb3jClientProvider> maybeExecutionClientProvider) {
final Optional<ExecutionWeb3jClientProvider> maybeExecutionWeb3jClientProvider) {
if (tekuConfig.beaconChain().interopConfig().isInteropEnabled()
|| (!tekuConfig.powchain().isEnabled() && maybeExecutionClientProvider.isEmpty())) {
|| (!tekuConfig.powchain().isEnabled() && maybeExecutionWeb3jClientProvider.isEmpty())) {
return Optional.empty();
}

return Optional.of(
new PowchainService(serviceConfig, tekuConfig.powchain(), maybeExecutionClientProvider));
new PowchainService(
serviceConfig, tekuConfig.powchain(), maybeExecutionWeb3jClientProvider));
}
}

0 comments on commit a7dd162

Please sign in to comment.