use of tech.pegasys.teku.validator.remote.apiclient.OkHttpValidatorRestApiClient in project teku by ConsenSys.
the class RemoteBeaconNodeApi method create.
public static BeaconNodeApi create(final ServiceConfig serviceConfig, final AsyncRunner asyncRunner, final URI beaconNodeApiEndpoint, final Spec spec, final boolean generateEarlyAttestations) {
final OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder().readTimeout(READ_TIMEOUT);
HttpUrl apiEndpoint = HttpUrl.get(beaconNodeApiEndpoint);
Preconditions.checkNotNull(apiEndpoint, String.format("Failed to convert remote api endpoint (%s) to a valid url", UrlSanitizer.sanitizePotentialUrl(beaconNodeApiEndpoint.toString())));
OkHttpClientAuthLoggingIntercepter.addAuthenticator(apiEndpoint, httpClientBuilder);
// Strip any authentication info from the URL to ensure it doesn't get logged.
apiEndpoint = apiEndpoint.newBuilder().username("").password("").build();
final OkHttpClient okHttpClient = httpClientBuilder.build();
final OkHttpValidatorRestApiClient apiClient = new OkHttpValidatorRestApiClient(apiEndpoint, okHttpClient);
final ValidatorApiChannel validatorApiChannel = new MetricRecordingValidatorApiChannel(serviceConfig.getMetricsSystem(), new RemoteValidatorApiHandler(spec, apiClient, asyncRunner));
final ValidatorTimingChannel validatorTimingChannel = serviceConfig.getEventChannels().getPublisher(ValidatorTimingChannel.class);
final BeaconChainEventAdapter beaconChainEventAdapter = new EventSourceBeaconChainEventAdapter(apiEndpoint, okHttpClient, new TimeBasedEventAdapter(new GenesisDataProvider(asyncRunner, validatorApiChannel), new RepeatingTaskScheduler(asyncRunner, serviceConfig.getTimeProvider()), serviceConfig.getTimeProvider(), validatorTimingChannel, spec), validatorTimingChannel, serviceConfig.getMetricsSystem(), generateEarlyAttestations);
return new RemoteBeaconNodeApi(beaconChainEventAdapter, validatorApiChannel);
}
use of tech.pegasys.teku.validator.remote.apiclient.OkHttpValidatorRestApiClient in project teku by ConsenSys.
the class RemoteSpecLoader method createApiClient.
static OkHttpValidatorRestApiClient createApiClient(final URI baseEndpoint) {
HttpUrl apiEndpoint = HttpUrl.get(baseEndpoint);
final OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder().readTimeout(30, TimeUnit.SECONDS);
OkHttpClientAuthLoggingIntercepter.addAuthenticator(apiEndpoint, httpClientBuilder);
// Strip any authentication info from the URL to ensure it doesn't get logged.
apiEndpoint = apiEndpoint.newBuilder().username("").password("").build();
final OkHttpClient okHttpClient = httpClientBuilder.build();
return new OkHttpValidatorRestApiClient(apiEndpoint, okHttpClient);
}
Aggregations