mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 05:18:30 +00:00
Add libp2p transport - tcp/ws/secio and multiplexing.
This commit is contained in:
@@ -2,8 +2,7 @@
|
||||
pub mod error;
|
||||
mod message_handler;
|
||||
mod messages;
|
||||
mod network_config;
|
||||
mod service;
|
||||
|
||||
pub use network_config::NetworkConfig;
|
||||
pub use libp2p::NetworkConfig;
|
||||
pub use service::Service;
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
use libp2p::{GossipsubConfig, GossipsubConfigBuilder};
|
||||
use std::net::IpAddr;
|
||||
use version;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
/// Network configuration for lighthouse.
|
||||
pub struct NetworkConfig {
|
||||
//TODO: stubbing networking initial params, change in the future
|
||||
/// IP address to listen on.
|
||||
pub listen_addresses: Option<Vec<IpAddr>>,
|
||||
/// Listen port UDP/TCP.
|
||||
pub listen_port: Option<u16>,
|
||||
/// Gossipsub configuration parameters.
|
||||
pub gs_config: GossipsubConfig,
|
||||
/// List of nodes to initially connect to.
|
||||
pub boot_nodes: Vec<String>,
|
||||
/// Client version
|
||||
pub client_version: String,
|
||||
}
|
||||
|
||||
impl Default for NetworkConfig {
|
||||
/// Generate a default network configuration.
|
||||
fn default() -> Self {
|
||||
NetworkConfig {
|
||||
listen_addresses: None,
|
||||
listen_port: None,
|
||||
gs_config: GossipsubConfigBuilder::new().build(),
|
||||
boot_nodes: Vec::new(),
|
||||
client_version: version::version(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl NetworkConfig {
|
||||
pub fn new() -> Self {
|
||||
NetworkConfig::default()
|
||||
}
|
||||
}
|
||||
@@ -30,10 +30,9 @@ impl Service {
|
||||
|
||||
// launch libp2p service
|
||||
let libp2p_log = log.new(o!("Service" => "Libp2p"));
|
||||
let libp2p_service = LibP2PService::new(libp2p_log);
|
||||
let libp2p_service = LibP2PService::new(config, libp2p_log);
|
||||
|
||||
// TODO: Spawn thread to handle libp2p messages and pass to message handler thread.
|
||||
|
||||
let network = Service {};
|
||||
|
||||
Ok((Arc::new(network), network_send))
|
||||
|
||||
Reference in New Issue
Block a user