mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 12:11:59 +00:00
Refactor ClientConfig, add serde to it
This commit is contained in:
@@ -3,17 +3,19 @@ mod key;
|
||||
mod metrics;
|
||||
|
||||
use beacon_chain::{BeaconChain, BeaconChainTypes};
|
||||
use clap::ArgMatches;
|
||||
use futures::Future;
|
||||
use iron::prelude::*;
|
||||
use network::NetworkMessage;
|
||||
use prometheus::Registry;
|
||||
use router::Router;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use slog::{info, o, warn};
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use tokio::runtime::TaskExecutor;
|
||||
|
||||
#[derive(PartialEq, Clone, Debug)]
|
||||
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct HttpServerConfig {
|
||||
pub enabled: bool,
|
||||
pub listen_address: String,
|
||||
@@ -30,6 +32,24 @@ impl Default for HttpServerConfig {
|
||||
}
|
||||
}
|
||||
|
||||
impl HttpServerConfig {
|
||||
pub fn apply_cli_args(&mut self, args: &ArgMatches) -> Result<(), &'static str> {
|
||||
if args.is_present("http") {
|
||||
self.enabled = true;
|
||||
}
|
||||
|
||||
if let Some(listen_address) = args.value_of("http-address") {
|
||||
self.listen_address = listen_address.to_string();
|
||||
}
|
||||
|
||||
if let Some(listen_port) = args.value_of("http-port") {
|
||||
self.listen_port = listen_port.to_string();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Build the `iron` HTTP server, defining the core routes.
|
||||
pub fn create_iron_http_server<T: BeaconChainTypes + 'static>(
|
||||
beacon_chain: Arc<BeaconChain<T>>,
|
||||
|
||||
Reference in New Issue
Block a user