From 6324b569f0c3fcf30dead8da78db4d39fdb7b93b Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Wed, 26 Aug 2020 18:23:59 +1000 Subject: [PATCH] Tidy endpoint --- beacon_node/http_api/src/lib.rs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index b1154c859c0..551cafa2dbb 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -145,23 +145,13 @@ pub fn serve( index_opt .and_then(|index| { - state - .validators - .get(index) - .map(|validator| (index, validator)) - }) - .and_then(|(index, validator)| { - state - .balances - .get(index) - .map(|balance| (index, validator, *balance)) - }) - .map(|(index, validator, balance)| { + let validator = state.validators.get(index)?; + let balance = *state.balances.get(index)?; let epoch = state.current_epoch(); let finalized_epoch = state.finalized_checkpoint.epoch; let far_future_epoch = chain.spec.far_future_epoch; - api_types::ValidatorData { + Some(api_types::ValidatorData { index: index as u64, balance, status: api_types::ValidatorStatus::from_validator( @@ -171,7 +161,7 @@ pub fn serve( far_future_epoch, ), validator: validator.clone(), - } + }) }) .ok_or_else(|| warp::reject::not_found()) })