Skip to content

Commit a911498

Browse files
kseosgkim126
authored andcommitted
Add event loop
1 parent 4293169 commit a911498

File tree

5 files changed

+21
-0
lines changed

5 files changed

+21
-0
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ authors = ["Kodebox <dev@kodebox.io>"]
77
[dependencies]
88
app_dirs = "^1.1.1"
99
clap = { version = "2", features = ["yaml"] }
10+
futures = "0.1"
1011
keccak-hash = { path = "util/hash" }
1112
log = "0.4.1"
1213
logs = { path = "logs" }
1314
env_logger = "0.5.3"
1415
panic_hook = { path = "util/panic_hook" }
1516
rpc = { path = "rpc" }
17+
tokio-core = "0.1.6"
1618

1719
[[bin]]
1820
path = "codechain/main.rs"

codechain/commands/start.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
use config;
22
use super::super::rpc;
3+
use super::super::event_loop::{event_loop, forever};
34

45
pub fn start(cfg: config::Config) -> Result<(), String> {
6+
let mut el = event_loop();
7+
58
let _rpc_server = rpc::new_http(cfg.rpc_config);
9+
el.run(forever()).unwrap();
610
Ok(())
711
}

codechain/event_loop.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use futures::{empty, Empty};
2+
use tokio_core::reactor::Core;
3+
4+
pub fn event_loop() -> Core {
5+
Core::new().unwrap()
6+
}
7+
8+
pub fn forever() -> Empty<(), ()> {
9+
empty()
10+
}

codechain/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#[macro_use]
22
extern crate clap;
3+
extern crate futures;
34

45
#[macro_use]
56
extern crate log;
7+
extern crate tokio_core;
68

79
extern crate app_dirs;
810
extern crate env_logger;
@@ -12,6 +14,7 @@ extern crate rpc as codechain_rpc;
1214

1315
mod config;
1416
mod commands;
17+
mod event_loop;
1518
mod rpc;
1619

1720
use app_dirs::AppInfo;

0 commit comments

Comments
 (0)