diff --git a/Cargo.toml b/Cargo.toml index 14f12e646..a0ea692b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,18 +21,8 @@ evmjit = { path = "rust-evmjit", optional = true } ethash = { path = "ethash" } num_cpus = "0.2" clippy = "0.0.37" -docopt = "0.6" -docopt_macros = "0.6" -ctrlc = "1.0" -jsonrpc-core = { version = "1.0", optional = true } -jsonrpc-http-server = { version = "1.0", optional = true } [features] jit = ["evmjit"] evm_debug = [] test-heavy = [] -rpc = ["jsonrpc-core", "jsonrpc-http-server"] - -[[bin]] -name = "client" -path = "src/bin/client/main.rs" diff --git a/bin/Cargo.toml b/bin/Cargo.toml new file mode 100644 index 000000000..ba258b586 --- /dev/null +++ b/bin/Cargo.toml @@ -0,0 +1,20 @@ +[package] +description = "Ethcore client." +name = "ethcore-client" +version = "0.1.0" +license = "GPL-3.0" +authors = ["Ethcore "] + +[dependencies] +log = "0.3" +env_logger = "0.3" +rustc-serialize = "0.3" +docopt = "0.6" +docopt_macros = "0.6" +ctrlc = "1.0" +ethcore-util = { path = "../util" } +ethcore-rpc = { path = "../rpc", optional = true } +ethcore = { path = ".." } + +[features] +rpc = ["ethcore-rpc"] diff --git a/src/bin/client/main.rs b/bin/src/main.rs similarity index 98% rename from src/bin/client/main.rs rename to bin/src/main.rs index 53d5b2cd6..942a5cf24 100644 --- a/src/bin/client/main.rs +++ b/bin/src/main.rs @@ -1,7 +1,6 @@ #![feature(plugin)] #![plugin(docopt_macros)] // required for serde, move it to a separate library -#![feature(custom_derive, custom_attribute)] extern crate docopt; extern crate rustc_serialize; extern crate ethcore_util as util; @@ -11,7 +10,7 @@ extern crate env_logger; extern crate ctrlc; #[cfg(feature = "rpc")] -mod rpc; +extern crate ethcore_rpc as rpc; use std::env; use log::{LogLevelFilter}; @@ -52,7 +51,7 @@ fn setup_log(init: &String) { #[cfg(feature = "rpc")] fn setup_rpc_server(client: Arc) { - use self::rpc::*; + use rpc::*; let mut server = HttpServer::new(1); server.add_delegate(Web3Client::new().to_delegate()); diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml new file mode 100644 index 000000000..d0f9f50e8 --- /dev/null +++ b/rpc/Cargo.toml @@ -0,0 +1,19 @@ +[package] +description = "Ethcore jsonrpc" +name = "ethcore-rpc" +version = "0.1.0" +license = "GPL-3.0" +authors = ["Marek Kotewicz , diff --git a/src/bin/client/rpc/impls/mod.rs b/rpc/src/impls/mod.rs similarity index 100% rename from src/bin/client/rpc/impls/mod.rs rename to rpc/src/impls/mod.rs diff --git a/src/bin/client/rpc/impls/net.rs b/rpc/src/impls/net.rs similarity index 88% rename from src/bin/client/rpc/impls/net.rs rename to rpc/src/impls/net.rs index f0109429c..a1d36de54 100644 --- a/src/bin/client/rpc/impls/net.rs +++ b/rpc/src/impls/net.rs @@ -1,6 +1,6 @@ //! Net rpc implementation. -use rpc::jsonrpc_core::*; -use rpc::Net; +use jsonrpc_core::*; +use traits::Net; pub struct NetClient; diff --git a/src/bin/client/rpc/impls/web3.rs b/rpc/src/impls/web3.rs similarity index 88% rename from src/bin/client/rpc/impls/web3.rs rename to rpc/src/impls/web3.rs index b7d8919e2..58e7858eb 100644 --- a/src/bin/client/rpc/impls/web3.rs +++ b/rpc/src/impls/web3.rs @@ -1,5 +1,5 @@ -use rpc::jsonrpc_core::*; -use rpc::Web3; +use jsonrpc_core::*; +use traits::Web3; pub struct Web3Client; diff --git a/src/bin/client/rpc/mod.rs b/rpc/src/lib.rs similarity index 80% rename from src/bin/client/rpc/mod.rs rename to rpc/src/lib.rs index 64f9137f0..148e9f134 100644 --- a/src/bin/client/rpc/mod.rs +++ b/rpc/src/lib.rs @@ -1,5 +1,12 @@ +#![feature(custom_derive, custom_attribute, plugin)] +#![plugin(serde_macros)] + +extern crate rustc_serialize; +extern crate serde; extern crate jsonrpc_core; extern crate jsonrpc_http_server; +extern crate ethcore_util as util; +extern crate ethcore; use self::jsonrpc_core::{IoHandler, IoDelegate}; @@ -14,7 +21,6 @@ mod types; pub use self::traits::{Web3, Eth, EthFilter, Net}; pub use self::impls::*; - pub struct HttpServer { handler: IoHandler, threads: usize diff --git a/src/bin/client/rpc/traits/eth.rs b/rpc/src/traits/eth.rs similarity index 99% rename from src/bin/client/rpc/traits/eth.rs rename to rpc/src/traits/eth.rs index 856111444..31e9df164 100644 --- a/src/bin/client/rpc/traits/eth.rs +++ b/rpc/src/traits/eth.rs @@ -1,6 +1,6 @@ //! Eth rpc interface. use std::sync::Arc; -use rpc::jsonrpc_core::*; +use jsonrpc_core::*; /// Eth rpc interface. pub trait Eth: Sized + Send + Sync + 'static { diff --git a/src/bin/client/rpc/traits/mod.rs b/rpc/src/traits/mod.rs similarity index 100% rename from src/bin/client/rpc/traits/mod.rs rename to rpc/src/traits/mod.rs diff --git a/src/bin/client/rpc/traits/net.rs b/rpc/src/traits/net.rs similarity index 95% rename from src/bin/client/rpc/traits/net.rs rename to rpc/src/traits/net.rs index 63c64edb3..4df8d7114 100644 --- a/src/bin/client/rpc/traits/net.rs +++ b/rpc/src/traits/net.rs @@ -1,6 +1,6 @@ //! Net rpc interface. use std::sync::Arc; -use rpc::jsonrpc_core::*; +use jsonrpc_core::*; /// Net rpc interface. pub trait Net: Sized + Send + Sync + 'static { diff --git a/src/bin/client/rpc/traits/web3.rs b/rpc/src/traits/web3.rs similarity index 94% rename from src/bin/client/rpc/traits/web3.rs rename to rpc/src/traits/web3.rs index b71c867aa..8e73d4304 100644 --- a/src/bin/client/rpc/traits/web3.rs +++ b/rpc/src/traits/web3.rs @@ -1,6 +1,6 @@ //! Web3 rpc interface. use std::sync::Arc; -use rpc::jsonrpc_core::*; +use jsonrpc_core::*; /// Web3 rpc interface. pub trait Web3: Sized + Send + Sync + 'static { diff --git a/src/bin/client/rpc/types/block.rs b/rpc/src/types/block.rs similarity index 84% rename from src/bin/client/rpc/types/block.rs rename to rpc/src/types/block.rs index 138140f60..c15c8186d 100644 --- a/src/bin/client/rpc/types/block.rs +++ b/rpc/src/types/block.rs @@ -1,7 +1,7 @@ use util::hash::*; use util::uint::*; -#[derive(Default, Serialize)] +#[derive(Default)] pub struct Block { hash: H256, #[serde(rename="parentHash")] @@ -35,7 +35,7 @@ fn test_block_serialize() { use serde_json; let block = Block::default(); - let serialized = serde_json::to_string(&block).unwrap(); - println!("s: {:?}", serialized); - assert!(false); + //let serialized = serde_json::to_string(&block).unwrap(); + //println!("s: {:?}", serialized); + //assert!(false); } diff --git a/src/bin/client/rpc/types/mod.rs b/rpc/src/types/mod.rs similarity index 100% rename from src/bin/client/rpc/types/mod.rs rename to rpc/src/types/mod.rs