Fixing some API bits

- Adding the validator routes into the main function.
 - Fixing the setting of the aggregation bits, and handling errors correctly.
 - Rust format fixes, and addressing compiler warnings.
This commit is contained in:
Luke Anderson
2019-09-01 15:41:03 +10:00
parent 8ea1167563
commit 632c13a9ec
3 changed files with 26 additions and 23 deletions

View File

@@ -3,9 +3,9 @@ use beacon_chain::{BeaconChain, BeaconChainTypes};
use bls::PublicKey;
use hex;
use hyper::{Body, Request};
use std::sync::Arc;
use store::{iter::AncestorIter, Store};
use types::{BeaconState, EthSpec, Hash256, RelativeEpoch, Slot};
use std::sync::Arc;
/// Parse a slot from a `0x` preixed string.
///
@@ -170,12 +170,16 @@ pub fn implementation_pending_response(_req: Request<Body>) -> ApiResult {
))
}
pub fn get_beacon_chain_from_request<T: BeaconChainTypes + 'static>(req: &Request<Body>) -> Result<Arc<BeaconChain<T>>, ApiError> {
pub fn get_beacon_chain_from_request<T: BeaconChainTypes + 'static>(
req: &Request<Body>,
) -> Result<Arc<BeaconChain<T>>, ApiError> {
// Get beacon state
let beacon_chain = req
.extensions()
.get::<Arc<BeaconChain<T>>>()
.ok_or_else(|| ApiError::ServerError("Request is missing the beacon chain extension".into()))?;
.ok_or_else(|| {
ApiError::ServerError("Request is missing the beacon chain extension".into())
})?;
let _ = beacon_chain
.ensure_state_caches_are_built()
.map_err(|e| ApiError::ServerError(format!("Unable to build state caches: {:?}", e)))?;