mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 19:02:42 +00:00
Add /network/listen_port API endpoint
This commit is contained in:
@@ -21,6 +21,21 @@ pub fn get_listen_addresses<T: BeaconChainTypes>(req: Request<Body>) -> ApiResul
|
||||
)))
|
||||
}
|
||||
|
||||
/// HTTP handle to return the list of libp2p multiaddr the client is listening on.
|
||||
///
|
||||
/// Returns a list of `Multiaddr`, serialized according to their `serde` impl.
|
||||
pub fn get_listen_port<T: BeaconChainTypes>(req: Request<Body>) -> ApiResult {
|
||||
let network = req
|
||||
.extensions()
|
||||
.get::<Arc<NetworkService<T>>>()
|
||||
.ok_or_else(|| ApiError::ServerError("NetworkService extension missing".to_string()))?;
|
||||
|
||||
Ok(success_response(Body::from(
|
||||
serde_json::to_string(&network.listen_port())
|
||||
.map_err(|e| ApiError::ServerError(format!("Unable to serialize port: {:?}", e)))?,
|
||||
)))
|
||||
}
|
||||
|
||||
/// HTTP handle to return the Discv5 ENR from the client's libp2p service.
|
||||
///
|
||||
/// ENR is encoded as base64 string.
|
||||
|
||||
Reference in New Issue
Block a user