Adds peers and connected_peers to lighthouse http API (#1030)

This commit is contained in:
Age Manning
2020-04-21 23:27:49 +10:00
committed by GitHub
parent fa7147f7c5
commit 9e42a851e4
9 changed files with 249 additions and 18 deletions

View File

@@ -3,9 +3,10 @@
//! Currently using identify to fingerprint.
use libp2p::identify::IdentifyInfo;
use serde::Serialize;
#[derive(Debug)]
/// Various client and protocol information related to a node.
#[derive(Clone, Debug, Serialize)]
pub struct Client {
/// The client's name (Ex: lighthouse, prism, nimbus, etc)
pub kind: ClientKind,
@@ -19,7 +20,7 @@ pub struct Client {
pub agent_string: Option<String>,
}
#[derive(Debug)]
#[derive(Clone, Debug, Serialize)]
pub enum ClientKind {
/// A lighthouse node (the best kind).
Lighthouse,
@@ -125,6 +126,11 @@ fn client_from_agent_version(agent_version: &str) -> (ClientKind, String, String
}
(kind, version, os_version)
}
Some("github.com") => {
let kind = ClientKind::Prysm;
let unknown = String::from("unknown");
(kind, unknown.clone(), unknown)
}
_ => {
let unknown = String::from("unknown");
(ClientKind::Unknown, unknown.clone(), unknown)