diff --git a/Cargo.lock b/Cargo.lock index a83d1b7340..800e76cf47 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,11 +5,13 @@ dependencies = [ "app_dirs 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.29.4 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.0", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "logs 0.1.0", "panic_hook 0.1.0", "rpc 0.1.0", + "tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 96cd90b850..381c50c7f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,12 +7,14 @@ authors = ["Kodebox "] [dependencies] app_dirs = "^1.1.1" clap = { version = "2", features = ["yaml"] } +futures = "0.1" keccak-hash = { path = "util/hash" } log = "0.4.1" logs = { path = "logs" } env_logger = "0.5.3" panic_hook = { path = "util/panic_hook" } rpc = { path = "rpc" } +tokio-core = "0.1.6" [[bin]] path = "codechain/main.rs" diff --git a/codechain/commands/start.rs b/codechain/commands/start.rs index b0b1f8cdbb..94b796ae82 100644 --- a/codechain/commands/start.rs +++ b/codechain/commands/start.rs @@ -1,7 +1,11 @@ use config; use super::super::rpc; +use super::super::event_loop::{event_loop, forever}; pub fn start(cfg: config::Config) -> Result<(), String> { + let mut el = event_loop(); + let _rpc_server = rpc::new_http(cfg.rpc_config); + el.run(forever()).unwrap(); Ok(()) } diff --git a/codechain/event_loop.rs b/codechain/event_loop.rs new file mode 100644 index 0000000000..b407c98d6f --- /dev/null +++ b/codechain/event_loop.rs @@ -0,0 +1,10 @@ +use futures::{empty, Empty}; +use tokio_core::reactor::Core; + +pub fn event_loop() -> Core { + Core::new().unwrap() +} + +pub fn forever() -> Empty<(), ()> { + empty() +} diff --git a/codechain/main.rs b/codechain/main.rs index 2537bdc203..93487ba6ec 100644 --- a/codechain/main.rs +++ b/codechain/main.rs @@ -1,8 +1,10 @@ #[macro_use] extern crate clap; +extern crate futures; #[macro_use] extern crate log; +extern crate tokio_core; extern crate app_dirs; extern crate env_logger; @@ -12,6 +14,7 @@ extern crate rpc as codechain_rpc; mod config; mod commands; +mod event_loop; mod rpc; use app_dirs::AppInfo;