Merge branch 'master' of github.com:ethcore/parity into ark

This commit is contained in:
arkpar 2016-01-24 19:21:31 +01:00
commit 02d33f6861
7 changed files with 68 additions and 22 deletions

View File

@ -20,6 +20,7 @@ time = "0.1"
evmjit = { path = "rust-evmjit", optional = true }
ethash = { path = "ethash" }
num_cpus = "0.2"
docopt = "0.6"
ctrlc = "1.0"
clippy = "0.0.37"

View File

@ -26,6 +26,11 @@
"gasLimit": "0x1388",
"stateRoot": "0xd7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544"
},
"nodes": [
"enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303",
"enode://de471bccee3d042261d52e9bff31458daecc406142b401d4cd848f677479f73104b9fdeb090af9583d3391b7f10cb2ba9e26865dd5fca4fcdc0fb1e3b723c786@54.94.239.50:30303",
"enode://1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082@52.74.57.123:30303"
],
"accounts": {
"0000000000000000000000000000000000000001": { "builtin": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
"0000000000000000000000000000000000000002": { "builtin": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },

View File

@ -1,6 +1,11 @@
#![feature(plugin)]
// TODO: uncomment once this can be made to work.
//#![plugin(docopt_macros)]
extern crate docopt;
extern crate rustc_serialize;
extern crate ethcore_util as util;
extern crate ethcore;
extern crate rustc_serialize;
extern crate log;
extern crate env_logger;
extern crate ctrlc;
@ -15,8 +20,27 @@ use ethcore::service::{ClientService, NetSyncMessage};
use ethcore::ethereum;
use ethcore::blockchain::CacheSize;
use ethcore::sync::EthSync;
use docopt::Docopt;
fn setup_log() {
const USAGE: &'static str = "
Parity. Ethereum Client.
Usage:
parity [options]
parity [options] <enode>...
Options:
-l --logging LOGGING Specify the logging level
-h --help Show this screen.
";
#[derive(Debug, RustcDecodable)]
struct Args {
arg_enode: Option<Vec<String>>,
flag_logging: Option<String>,
}
fn setup_log(init: &Option<String>) {
let mut builder = LogBuilder::new();
builder.filter(None, LogLevelFilter::Info);
@ -24,18 +48,25 @@ fn setup_log() {
builder.parse(&env::var("RUST_LOG").unwrap());
}
if let &Some(ref x) = init {
builder.parse(x);
}
builder.init().unwrap();
}
fn main() {
setup_log();
let spec = ethereum::new_frontier();
let mut net_settings = NetworkConfiguration::new();
let args: Vec<_> = env::args().collect();
if args.len() == 2 {
net_settings.boot_nodes = Some(vec! [args[1].trim_matches('\"').to_string()]);
}
let args: Args = Docopt::new(USAGE).and_then(|d| d.decode()).unwrap_or_else(|e| e.exit());
setup_log(&args.flag_logging);
let spec = ethereum::new_frontier();
let init_nodes = match &args.arg_enode {
&None => spec.nodes().clone(),
&Some(ref enodes) => enodes.clone(),
};
let mut net_settings = NetworkConfiguration::new();
net_settings.boot_nodes = init_nodes;
let mut service = ClientService::start(spec, net_settings).unwrap();
let io_handler = Arc::new(ClientIoHandler { client: service.client(), info: Default::default(), sync: service.sync() });
service.io().register_handler(io_handler).expect("Error registering IO handler");

View File

@ -91,6 +91,8 @@ extern crate evmjit;
#[macro_use]
extern crate ethcore_util as util;
// NOTE: Add doc parser exception for these pub declarations.
/// TODO [Gav Wood] Please document me
pub mod common;
/// TODO [Tomusdrw] Please document me

View File

@ -47,6 +47,11 @@ impl ClientService {
})
}
/// Get the network service.
pub fn add_node(&mut self, _enode: &str) {
unimplemented!();
}
/// TODO [arkpar] Please document me
pub fn io(&mut self) -> &mut IoService<NetSyncMessage> {
self.net_service.io()

View File

@ -73,6 +73,9 @@ pub struct Spec {
/// TODO [Gav Wood] Please document me
pub engine_name: String,
/// Known nodes on the network in enode format.
pub nodes: Vec<String>,
// Parameters concerning operation of the specific engine we're using.
// Name -> RLP-encoded value
/// TODO [Gav Wood] Please document me
@ -128,6 +131,9 @@ impl Spec {
self.state_root_memo.read().unwrap().as_ref().unwrap().clone()
}
/// Get the known knodes of the network in enode format.
pub fn nodes(&self) -> &Vec<String> { &self.nodes }
/// TODO [Gav Wood] Please document me
pub fn genesis_header(&self) -> Header {
Header {
@ -197,6 +203,10 @@ impl FromJson for Spec {
}
}
let nodes = if let Some(&Json::Array(ref ns)) = json.find("nodes") {
ns.iter().filter_map(|n| if let Json::String(ref s) = *n { Some(s.clone()) } else {None}).collect()
} else { Vec::new() };
let genesis = &json["genesis"];//.as_object().expect("No genesis object in JSON");
let (seal_fields, seal_rlp) = {
@ -213,12 +223,12 @@ impl FromJson for Spec {
)
}
};
Spec {
name: json.find("name").map_or("unknown", |j| j.as_string().unwrap()).to_owned(),
engine_name: json["engineName"].as_string().unwrap().to_owned(),
engine_params: json_to_rlp_map(&json["params"]),
nodes: nodes,
builtins: builtins,
parent_hash: H256::from_str(&genesis["parentHash"].as_string().unwrap()[2..]).unwrap(),
author: Address::from_str(&genesis["author"].as_string().unwrap()[2..]).unwrap(),

View File

@ -42,7 +42,7 @@ pub struct NetworkConfiguration {
/// Pin to boot nodes only
pub pin: bool,
/// List of initial node addresses
pub boot_nodes: Option<Vec<String>>,
pub boot_nodes: Vec<String>,
/// Use provided node key instead of default
pub use_secret: Option<Secret>,
}
@ -56,7 +56,7 @@ impl NetworkConfiguration {
nat_enabled: true,
discovery_enabled: true,
pin: false,
boot_nodes: None,
boot_nodes: Vec::new(),
use_secret: None,
}
}
@ -304,16 +304,8 @@ impl<Message> Host<Message> where Message: Send + Sync + Clone {
*/
let boot_nodes = host.info.read().unwrap().config.boot_nodes.clone();
if boot_nodes.is_none() {
// GO bootnodes
host.add_node("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303"); // IE
host.add_node("enode://de471bccee3d042261d52e9bff31458daecc406142b401d4cd848f677479f73104b9fdeb090af9583d3391b7f10cb2ba9e26865dd5fca4fcdc0fb1e3b723c786@54.94.239.50:30303"); // BR
host.add_node("enode://1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082@52.74.57.123:30303"); // SG
}
else {
for n in boot_nodes.unwrap() {
host.add_node(&n);
}
for n in boot_nodes {
host.add_node(&n);
}
host
}