Implement skeleton network/sync framework.

This commit is contained in:
Age Manning
2019-03-04 18:31:01 +11:00
parent 3b8f29a914
commit b68adc1ae3
16 changed files with 147 additions and 39 deletions

View File

@@ -56,7 +56,7 @@ impl ClientConfig {
// TODO: Handle list of addresses
if let Some(listen_address_str) = args.value_of("listen_address") {
if let Ok(listen_address) = listen_address_str.parse::<IpAddr>() {
config.net_conf.listen_address = Some(Vec::new(listen_address));
config.net_conf.listen_addresses = Some(vec![listen_address]);
} else {
error!(log, "Invalid IP Address"; "Address" => listen_address_str);
return Err("Invalid IP Address");

View File

@@ -1,8 +1,14 @@
// generates error types
use network;
use error_chain::{
error_chain, error_chain_processing, impl_error_chain_kind, impl_error_chain_processed,
impl_extract_backtrace,
};
error_chain! {}
error_chain! {
links {
Network(network::error::Error, network::error::ErrorKind);
}
}

View File

@@ -11,9 +11,10 @@ pub use client_types::ClientTypes;
//use beacon_chain::BeaconChain;
use exit_future::{Exit, Signal};
use network::Service as NetworkService;
use slog::o;
use std::marker::PhantomData;
//use std::sync::Arc;
use network::NetworkService;
use std::sync::Arc;
use tokio::runtime::TaskExecutor;
/// Main beacon node client service. This provides the connection and initialisation of the clients
@@ -39,11 +40,11 @@ impl<T: ClientTypes> Client<T> {
// TODO: generate a beacon_chain service.
// start the network service, libp2p and syncing threads
// Start the network service, libp2p and syncing threads
// TODO: Add beacon_chain reference to network parameters
let network_config = config.net_config;
let network_logger = client.log.new(o!("Service" => "Network"));
let (network, network_send) = NetworkService::new(network_config, network_logger);
let network_config = config.net_conf.clone();
let network_logger = log.new(o!("Service" => "Network"));
let (network, network_send) = NetworkService::new(network_config, network_logger)?;
Ok(Client {
config,

View File

@@ -4,7 +4,7 @@ use db::ClientDB;
use exit_future::Exit;
use fork_choice::ForkChoice;
use futures::{Future, Stream};
use slog::{debug, info};
use slog::{debug, info, o};
use slot_clock::SlotClock;
use std::sync::Arc;
use std::time::{Duration, Instant};
@@ -26,7 +26,7 @@ pub fn run<T: ClientTypes>(client: &Client<T>, executor: TaskExecutor, exit: Exi
};
// map error and spawn
let log = client.logger();
let log = client.log.clone();
let heartbeat_interval = interval
.map_err(move |e| debug!(log, "Timer error {}", e))
.for_each(heartbeat);