mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 04:01:51 +00:00
Further restructuring futures API.
- Adding try_future! macros where necessary - Returning ApiResult and mapping it to future instead - Upgrading POST publish block to return a future directly
This commit is contained in:
@@ -5,19 +5,13 @@ use hyper::{Body, Request};
|
||||
use version;
|
||||
|
||||
/// Read the version string from the current Lighthouse build.
|
||||
pub fn get_version(req: Request<Body>) -> BoxFut {
|
||||
success_response_json(req, &version::version())
|
||||
pub fn get_version(req: Request<Body>) -> ApiResult {
|
||||
success_response_2_json(req, &version::version())
|
||||
}
|
||||
|
||||
/// Read the genesis time from the current beacon chain state.
|
||||
pub fn get_genesis_time<T: BeaconChainTypes + 'static>(req: Request<Body>) -> BoxFut {
|
||||
let bc = get_beacon_chain_from_request::<T>(&req);
|
||||
let (_beacon_chain, head_state) = match bc {
|
||||
Ok((bc, hs)) => (bc, hs),
|
||||
Err(e) => {
|
||||
return e.into();
|
||||
}
|
||||
};
|
||||
pub fn get_genesis_time<T: BeaconChainTypes + 'static>(req: Request<Body>) -> ApiResult {
|
||||
let (_beacon_chain, head_state) = get_beacon_chain_from_request::<T>(&req)?;
|
||||
let gen_time: u64 = head_state.genesis_time;
|
||||
success_response(req, &gen_time)
|
||||
success_response_2(req, &gen_time)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user