mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 04:48:21 +00:00
Fleshed out some API endpoints.
- Added the /beacon/validator/block endpoint for GET (untested) - Added the /beacon/fork endpoint for GET - Cleaned up a bunch of unused imports & variables - Removed '/network/block_discovery' endpoint
This commit is contained in:
@@ -130,6 +130,22 @@ pub fn get_block_root<T: BeaconChainTypes + 'static>(req: Request<Body>) -> ApiR
|
||||
Ok(success_response(Body::from(json)))
|
||||
}
|
||||
|
||||
/// HTTP handler to return the `Fork` of the current head.
|
||||
pub fn get_fork<T: BeaconChainTypes + 'static>(req: Request<Body>) -> ApiResult {
|
||||
let beacon_chain = req
|
||||
.extensions()
|
||||
.get::<Arc<BeaconChain<T>>>()
|
||||
.ok_or_else(|| ApiError::ServerError("Beacon chain extension missing".to_string()))?;
|
||||
|
||||
let chain_head = beacon_chain.head();
|
||||
|
||||
let json: String = serde_json::to_string(&chain_head.beacon_state.fork).map_err(|e| {
|
||||
ApiError::ServerError(format!("Unable to serialize BeaconState::Fork: {:?}", e))
|
||||
})?;
|
||||
|
||||
Ok(success_response(Body::from(json)))
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(bound = "T: EthSpec")]
|
||||
pub struct StateResponse<T: EthSpec> {
|
||||
|
||||
Reference in New Issue
Block a user