Getting regular endpoint functions to return futures.

- Wrapped endpoint functions in new into_boxfut function
 - Undid changes to Network API service, now returning ApiResult again.
 - Cleaning up of functions, and removal of success_response functions in updated endpoints.
 - A bunch of other clean-ups.
This commit is contained in:
Luke Anderson
2019-09-12 15:20:31 +10:00
parent 82f4303787
commit cd8f40b4b7
7 changed files with 50 additions and 52 deletions

View File

@@ -1,4 +1,5 @@
use crate::helpers::*;
use crate::response_builder::ResponseBuilder;
use crate::{ApiResult, BoxFut};
use beacon_chain::BeaconChainTypes;
use hyper::{Body, Request};
@@ -6,13 +7,12 @@ use version;
/// Read the version string from the current Lighthouse build.
pub fn get_version(req: Request<Body>) -> ApiResult {
success_response_2_json(req, &version::version())
ResponseBuilder::new(&req).body_json(&version::version())
}
/// Read the genesis time from the current beacon chain state.
pub fn get_genesis_time<T: BeaconChainTypes + 'static>(req: Request<Body>) -> ApiResult {
let beacon_chain = get_beacon_chain_from_request::<T>(&req)?;
let head_state = get_head_state(beacon_chain)?;
let gen_time: u64 = head_state.genesis_time;
success_response_2(req, &gen_time)
ResponseBuilder::new(&req).body(&head_state.genesis_time)
}