Skip to content

Commit

Permalink
Don't have block_service as an Option
Browse files Browse the repository at this point in the history
  • Loading branch information
macladson committed Aug 23, 2024
1 parent 5cc2c13 commit b5445a0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
12 changes: 2 additions & 10 deletions validator_client/src/http_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl From<String> for Error {
pub struct Context<T: SlotClock, E: EthSpec> {
pub task_executor: TaskExecutor,
pub api_secret: ApiSecret,
pub block_service: Option<BlockService<T, E>>,
pub block_service: BlockService<T, E>,
pub validator_store: Option<Arc<ValidatorStore<T, E>>>,
pub validator_dir: Option<PathBuf>,
pub secrets_dir: Option<PathBuf>,
Expand Down Expand Up @@ -172,15 +172,7 @@ pub fn serve<T: 'static + SlotClock + Clone, E: EthSpec>(
};

let inner_block_service = ctx.block_service.clone();
let block_service_filter = warp::any()
.map(move || inner_block_service.clone())
.and_then(|block_service: Option<_>| async move {
block_service.ok_or_else(|| {
warp_utils::reject::custom_not_found(
"block service is not initialized.".to_string(),
)
})
});
let block_service_filter = warp::any().map(move || inner_block_service.clone());

let inner_validator_store = ctx.validator_store.clone();
let validator_store_filter = warp::any()
Expand Down
5 changes: 4 additions & 1 deletion validator_client/src/http_api/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::doppelganger_service::DoppelgangerService;
use crate::key_cache::{KeyCache, CACHE_FILENAME};
use crate::BlockServiceBuilder;
use crate::{
http_api::{ApiSecret, Config as HttpConfig, Context},
initialized_validators::{InitializedValidators, OnDecryptFailure},
Expand Down Expand Up @@ -127,7 +128,9 @@ impl ApiTester {
let context = Arc::new(Context {
task_executor: test_runtime.task_executor.clone(),
api_secret,
block_service: None,
block_service: BlockServiceBuilder::new()
.build()
.expect("Should build block service"),
validator_dir: Some(validator_dir.path().into()),
secrets_dir: Some(secrets_dir.path().into()),
validator_store: Some(validator_store.clone()),
Expand Down
5 changes: 4 additions & 1 deletion validator_client/src/http_api/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
mod keystores;

use crate::doppelganger_service::DoppelgangerService;
use crate::BlockServiceBuilder;
use crate::{
http_api::{ApiSecret, Config as HttpConfig, Context},
initialized_validators::InitializedValidators,
Expand Down Expand Up @@ -115,7 +116,9 @@ impl ApiTester {
let context = Arc::new(Context {
task_executor: test_runtime.task_executor.clone(),
api_secret,
block_service: None,
block_service: BlockServiceBuilder::new()
.build()
.expect("Should build block service"),
validator_dir: Some(validator_dir.path().into()),
secrets_dir: Some(secrets_dir.path().into()),
validator_store: Some(validator_store.clone()),
Expand Down
2 changes: 1 addition & 1 deletion validator_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ impl<E: EthSpec> ProductionValidatorClient<E> {
let ctx = Arc::new(http_api::Context {
task_executor: self.context.executor.clone(),
api_secret,
block_service: Some(self.block_service.clone()),
block_service: self.block_service.clone(),
validator_store: Some(self.validator_store.clone()),
validator_dir: Some(self.config.validator_dir.clone()),
secrets_dir: Some(self.config.secrets_dir.clone()),
Expand Down

0 comments on commit b5445a0

Please sign in to comment.