Starts initialisation of beacon chain in the client

This commit is contained in:
Age Manning
2019-03-18 16:16:54 +11:00
parent 2e0c8e2e47
commit bbad4bfa19
10 changed files with 207 additions and 80 deletions

View File

@@ -21,31 +21,36 @@ use tokio::runtime::TaskExecutor;
/// sub-services in multiple threads.
pub struct Client<T: ClientTypes> {
config: ClientConfig,
// beacon_chain: Arc<BeaconChain<T, U, F>>,
beacon_chain: Arc<BeaconChain<T::DB, T::SlotClock, T::ForkChoice>>,
pub network: Arc<NetworkService>,
pub exit: exit_future::Exit,
pub exit_signal: Signal,
log: slog::Logger,
phantom: PhantomData<T>,
}
impl<T: ClientTypes> Client<T> {
/// Generate an instance of the client. Spawn and link all internal subprocesses.
pub fn new(
config: ClientConfig,
client_type: T,
log: slog::Logger,
executor: &TaskExecutor,
) -> error::Result<Self> {
let (exit_signal, exit) = exit_future::signal();
// TODO: generate a beacon_chain service.
// generate a beacon chain
let beacon_chain = client_type.initialise_beacon_chain(&config);
// Start the network service, libp2p and syncing threads
// TODO: Add beacon_chain reference to network parameters
let network_config = config.net_conf.clone();
let network_config = &config.net_conf;
let network_logger = log.new(o!("Service" => "Network"));
let (network, network_send) =
NetworkService::new(network_config, executor, network_logger)?;
let (network, network_send) = NetworkService::new(
beacon_chain.clone(),
network_config,
executor,
network_logger,
)?;
Ok(Client {
config,