Adds bootnodes to chainspec. Handles type correctly

This commit is contained in:
Age Manning
2019-03-08 12:15:57 +11:00
parent c5a7c62d5d
commit 21032334ac
9 changed files with 49 additions and 13 deletions

View File

@@ -7,13 +7,11 @@ edition = "2018"
[dependencies]
beacon_chain = { path = "../beacon_chain" }
network = { path = "../network" }
libp2p = { path = "../libp2p" }
sync = { path = "../sync" }
db = { path = "../db" }
fork_choice = { path = "../../eth2/fork_choice" }
types = { path = "../../eth2/types" }
slot_clock = { path = "../../eth2/utils/slot_clock" }
error-chain = "0.12.0"
slog = "^2.2.3"
tokio = "0.1.15"

View File

@@ -1,13 +1,13 @@
use clap::ArgMatches;
use db::DBType;
use fork_choice::ForkChoiceAlgorithm;
use libp2p::multiaddr::ToMultiaddr;
use network::NetworkConfig;
use slog::error;
use std::fs;
use std::net::IpAddr;
use std::net::SocketAddr;
use std::path::PathBuf;
use types::multiaddr::ToMultiaddr;
use types::ChainSpec;
/// Stores the client configuration for this Lighthouse instance.
@@ -32,11 +32,15 @@ impl Default for ClientConfig {
};
fs::create_dir_all(&data_dir)
.unwrap_or_else(|_| panic!("Unable to create {:?}", &data_dir));
let default_spec = ChainSpec::lighthouse_testnet();
let default_net_conf = NetworkConfig::new(default_spec.boot_nodes.clone());
Self {
data_dir: data_dir.clone(),
// default to foundation for chain specs
spec: ChainSpec::foundation(),
net_conf: NetworkConfig::default(),
spec: default_spec,
net_conf: default_net_conf,
// default to bitwise LMD Ghost
fork_choice: ForkChoiceAlgorithm::BitwiseLMDGhost,
// default to memory db for now

View File

@@ -7,8 +7,8 @@ edition = "2018"
[dependencies]
# SigP repository until PR is merged
libp2p = { git = "https://github.com/SigP/rust-libp2p", branch = "gossipsub" }
types = { path = "../../eth2/types" }
slog = "2.4.1"
version = { path = "../version" }
tokio = "0.1.16"
futures = "0.1.25"
parity-multiaddr = "0.2.0"

View File

@@ -6,11 +6,11 @@ mod behaviour;
mod network_config;
mod service;
pub use libp2p::multiaddr;
pub use libp2p::Multiaddr;
pub use libp2p::{
gossipsub::{GossipsubConfig, GossipsubConfigBuilder},
PeerId,
};
pub use network_config::NetworkConfig;
pub use service::Service;
pub use types::multiaddr;
pub use types::Multiaddr;

View File

@@ -1,6 +1,6 @@
use crate::Multiaddr;
use libp2p::gossipsub::{GossipsubConfig, GossipsubConfigBuilder};
use libp2p::secio;
use libp2p::Multiaddr;
use std::fmt;
#[derive(Clone)]
@@ -40,8 +40,11 @@ impl Default for NetworkConfig {
}
impl NetworkConfig {
pub fn new() -> Self {
NetworkConfig::default()
pub fn new(boot_nodes: Vec<Multiaddr>) -> Self {
let mut conf = NetworkConfig::default();
conf.boot_nodes = boot_nodes;
conf
}
}

View File

@@ -1,4 +1,5 @@
use crate::behaviour::Behaviour;
use crate::multiaddr::Protocol;
use crate::NetworkConfig;
use futures::prelude::*;
use libp2p::core::{
@@ -7,7 +8,6 @@ use libp2p::core::{
transport::boxed::Boxed,
upgrade::{InboundUpgradeExt, OutboundUpgradeExt},
};
use libp2p::multiaddr::Protocol;
use libp2p::{core, secio, Transport};
use libp2p::{PeerId, Swarm};
use slog::{debug, info, warn};