mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 12:11:59 +00:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user