openethereum/src/bin/client.rs

34 lines
858 B
Rust
Raw Normal View History

2015-12-22 22:19:50 +01:00
extern crate ethcore_util as util;
2016-01-07 16:08:12 +01:00
extern crate ethcore;
extern crate rustc_serialize;
2016-01-09 23:21:57 +01:00
extern crate env_logger;
2015-12-22 22:19:50 +01:00
use std::io::*;
2016-01-07 16:08:12 +01:00
use std::env;
use std::sync::Arc;
use util::hash::*;
2015-12-22 22:19:50 +01:00
use util::network::{NetworkService};
2016-01-07 16:08:12 +01:00
use ethcore::client::Client;
use ethcore::sync::EthSync;
use ethcore::ethereum;
2016-01-11 11:51:31 +01:00
use ethcore::ethereum::ethash::Ethash;
2015-12-22 22:19:50 +01:00
fn main() {
2016-01-09 23:21:57 +01:00
::env_logger::init().ok();
2016-01-07 16:08:12 +01:00
let mut service = NetworkService::start().unwrap();
2016-01-07 20:49:36 +01:00
//TODO: replace with proper genesis and chain params.
2016-01-11 11:51:31 +01:00
let engine = Ethash::new_arc(ethereum::new_frontier());
2016-01-07 16:08:12 +01:00
let mut dir = env::temp_dir();
dir.push(H32::random().hex());
2016-01-11 11:51:31 +01:00
let client = Arc::new(Client::new(engine, &dir));
2016-01-09 18:40:13 +01:00
EthSync::register(&mut service, client);
2015-12-22 22:19:50 +01:00
loop {
let mut cmd = String::new();
stdin().read_line(&mut cmd).unwrap();
2016-01-07 16:08:12 +01:00
if cmd == "quit\n" || cmd == "exit\n" || cmd == "q\n" {
2015-12-22 22:19:50 +01:00
break;
}
}
}