libra 启动流程分两步:启动libraSwarm和交互客户端(可选)
libra启动分4步:
let config = config_builder.build().unwrap()
LibraNode::launch {
…
let mut node = node_command
.spawn() // 启动子进程 调用 libra_node/main.rs:main
…
}
executable_helpers::helpers::setup_executable
libra_node::main_node::setup_environment {
…
let mut instant = Instant::now();
//启动存储服务
let storage = start_storage_service(&node_config);
debug!(
“Storage service started in {} ms”,
instant.elapsed().as_millis()
);
//启动执行组件
instant = Instant::now();
let execution = ServerHandle::setup(setup_executor(&node_config));
debug!(
“Execution service started in {} ms”,
instant.elapsed().as_millis()
);
//启动网络服务
instant = Instant::now();
let (
(mempool_network_sender, mempool_network_events),
(consensus_network_sender, consensus_network_events),
network_runtime,
) = setup_network(&node_config);
debug!(“Network started in {} ms”, instant.elapsed().as_millis());
//启动AC
instant = Instant::now();
let (ac_server, ac_client) = setup_ac(&node_config);
let ac = ServerHandle::setup(ac_server);
debug!(“AC started in {} ms”, instant.elapsed().as_millis());
//启动内存池
instant = Instant::now();
let mempool =
MempoolRuntime::bootstrap(&node_config, mempool_network_sender, mempool_network_events);
debug!(“Mempool started in {} ms”, instant.elapsed().as_millis());
let debug_if = ServerHandle::setup(setup_debug_interface(&node_config));
// 启动度量服务
let metrics_port = node_config.debug_interface.metrics_server_port;
let metric_host = node_config.debug_interface.address.clone();
thread::spawn(move || metric_server::start_server(metric_host, metrics_port));
//启动一致性服务
instant = Instant::now();
let mut consensus_provider = make_consensus_provider(
&node_config,
consensus_network_sender,
consensus_network_events,
);
consensus_provider
.start()
.expect(“Failed to start consensus. Can’t proceed.”);
debug!(“Consensus started in {} ms”, instant.elapsed().as_millis());
…
}
register_signals(Arc::clone(&term))
swarm.wait_for_startup()?;
swarm.wait_for_connectivity()?;
libra_swarm/main.rs:main->client::InteractiveClient::new_with_inherit_io