extern crate slog; pub mod config; mod metrics; mod notifier; pub mod builder; pub mod error; use beacon_chain::BeaconChain; use eth2_libp2p::{Enr, Multiaddr, NetworkGlobals}; use std::net::SocketAddr; use std::sync::Arc; pub use beacon_chain::{BeaconChainTypes, Eth1ChainBackend}; pub use builder::ClientBuilder; pub use config::{ClientGenesis, Config as ClientConfig}; pub use eth2_config::Eth2Config; /// The core "beacon node" client. /// /// Holds references to running services, cleanly shutting them down when dropped. pub struct Client { beacon_chain: Option>>, network_globals: Option>>, http_listen_addr: Option, websocket_listen_addr: Option, /// Exit channels will complete/error when dropped, causing each service to exit gracefully. _exit_channels: Vec>, } impl Client { /// Returns an `Arc` reference to the client's `BeaconChain`, if it was started. pub fn beacon_chain(&self) -> Option>> { self.beacon_chain.clone() } /// Returns the address of the client's HTTP API server, if it was started. pub fn http_listen_addr(&self) -> Option { self.http_listen_addr } /// Returns the address of the client's WebSocket API server, if it was started. pub fn websocket_listen_addr(&self) -> Option { self.websocket_listen_addr } /// Returns the port of the client's libp2p stack, if it was started. pub fn libp2p_listen_port(&self) -> Option { self.network_globals.as_ref().map(|n| n.listen_port_tcp()) } /// Returns the list of libp2p addresses the client is listening to. pub fn libp2p_listen_addresses(&self) -> Option> { self.network_globals.as_ref().map(|n| n.listen_multiaddrs()) } /// Returns the local libp2p ENR of this node, for network discovery. pub fn enr(&self) -> Option { self.network_globals.as_ref()?.local_enr() } }