From 61c64d264b6ee81c9f11be3bfc429f1d49ffa995 Mon Sep 17 00:00:00 2001 From: debris Date: Wed, 27 Jan 2016 17:08:59 +0100 Subject: [PATCH 1/3] moved rust-evmjit -> evmjit, added clippy and basic docs to rpc crate --- Cargo.toml | 2 +- bin/src/main.rs | 1 - {rust-evmjit => evmjit}/.gitignore | 0 {rust-evmjit => evmjit}/Cargo.toml | 0 {rust-evmjit => evmjit}/src/lib.rs | 0 rpc/Cargo.toml | 1 + rpc/src/impls/eth.rs | 5 +++++ rpc/src/impls/net.rs | 2 ++ rpc/src/impls/web3.rs | 3 +++ rpc/src/lib.rs | 8 +++++++- rpc/src/traits/eth.rs | 1 + util/Cargo.toml | 2 +- 12 files changed, 21 insertions(+), 4 deletions(-) rename {rust-evmjit => evmjit}/.gitignore (100%) rename {rust-evmjit => evmjit}/Cargo.toml (100%) rename {rust-evmjit => evmjit}/src/lib.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 489c1f27e..872e1e675 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ heapsize = "0.2.0" rust-crypto = "0.2.34" time = "0.1" #interpolate_idents = { git = "https://github.com/SkylerLipthay/interpolate_idents" } -evmjit = { path = "rust-evmjit", optional = true } +evmjit = { path = "evmjit", optional = true } ethash = { path = "ethash" } num_cpus = "0.2" clippy = "0.0.37" diff --git a/bin/src/main.rs b/bin/src/main.rs index 942a5cf24..402a0c7c1 100644 --- a/bin/src/main.rs +++ b/bin/src/main.rs @@ -1,6 +1,5 @@ #![feature(plugin)] #![plugin(docopt_macros)] -// required for serde, move it to a separate library extern crate docopt; extern crate rustc_serialize; extern crate ethcore_util as util; diff --git a/rust-evmjit/.gitignore b/evmjit/.gitignore similarity index 100% rename from rust-evmjit/.gitignore rename to evmjit/.gitignore diff --git a/rust-evmjit/Cargo.toml b/evmjit/Cargo.toml similarity index 100% rename from rust-evmjit/Cargo.toml rename to evmjit/Cargo.toml diff --git a/rust-evmjit/src/lib.rs b/evmjit/src/lib.rs similarity index 100% rename from rust-evmjit/src/lib.rs rename to evmjit/src/lib.rs diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 1f10180d6..ab7072c85 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -15,4 +15,5 @@ jsonrpc-core = "1.1" jsonrpc-http-server = "1.1" ethcore-util = { path = "../util" } ethcore = { path = ".." } +clippy = "0.0.37" diff --git a/rpc/src/impls/eth.rs b/rpc/src/impls/eth.rs index ac27111d6..91c05541a 100644 --- a/rpc/src/impls/eth.rs +++ b/rpc/src/impls/eth.rs @@ -1,3 +1,4 @@ +//! Eth rpc implementation. use std::sync::Arc; use jsonrpc_core::*; use util::hash::*; @@ -8,11 +9,13 @@ use ethcore::views::*; use traits::{Eth, EthFilter}; use types::Block; +/// Eth rpc implementation. pub struct EthClient { client: Arc, } impl EthClient { + /// Creates new EthClient. pub fn new(client: Arc) -> Self { EthClient { client: client @@ -100,11 +103,13 @@ impl Eth for EthClient { } } +/// Eth filter rpc implementation. pub struct EthFilterClient { client: Arc } impl EthFilterClient { + /// Creates new Eth filter client. pub fn new(client: Arc) -> Self { EthFilterClient { client: client diff --git a/rpc/src/impls/net.rs b/rpc/src/impls/net.rs index a1d36de54..20ed4d077 100644 --- a/rpc/src/impls/net.rs +++ b/rpc/src/impls/net.rs @@ -2,9 +2,11 @@ use jsonrpc_core::*; use traits::Net; +/// Net rpc implementation. pub struct NetClient; impl NetClient { + /// Creates new NetClient. pub fn new() -> Self { NetClient } } diff --git a/rpc/src/impls/web3.rs b/rpc/src/impls/web3.rs index 50eb9c6f5..0188aa179 100644 --- a/rpc/src/impls/web3.rs +++ b/rpc/src/impls/web3.rs @@ -1,9 +1,12 @@ +//! Web3 rpc implementation. use jsonrpc_core::*; use traits::Web3; +/// Web3 rpc implementation. pub struct Web3Client; impl Web3Client { + /// Creates new Web3Client. pub fn new() -> Self { Web3Client } } diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 43a24a1fb..816eeb4a4 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -1,6 +1,8 @@ +//! Ethcore rpc. +#![warn(missing_docs)] #![feature(custom_derive, custom_attribute, plugin)] -#![feature(slice_patterns)] #![plugin(serde_macros)] +#![plugin(clippy)] extern crate serde; extern crate serde_json; @@ -22,12 +24,14 @@ mod types; pub use self::traits::{Web3, Eth, EthFilter, Net}; pub use self::impls::*; +/// Http server. pub struct HttpServer { handler: IoHandler, threads: usize } impl HttpServer { + /// Construct new http server object with given number of threads. pub fn new(threads: usize) -> HttpServer { HttpServer { handler: IoHandler::new(), @@ -35,10 +39,12 @@ impl HttpServer { } } + /// Add io delegate. pub fn add_delegate(&mut self, delegate: IoDelegate) where D: Send + Sync + 'static { self.handler.add_delegate(delegate); } + /// Start server asynchronously in new thread pub fn start_async(self, addr: &str) { let server = jsonrpc_http_server::Server::new(self.handler, self.threads); server.start_async(addr) diff --git a/rpc/src/traits/eth.rs b/rpc/src/traits/eth.rs index 63aadbc74..25756a713 100644 --- a/rpc/src/traits/eth.rs +++ b/rpc/src/traits/eth.rs @@ -44,6 +44,7 @@ pub trait Eth: Sized + Send + Sync + 'static { } } +/// Eth filters rpc api (polling). // TODO: do filters api properly pub trait EthFilter: Sized + Send + Sync + 'static { /// Returns id of new block filter diff --git a/util/Cargo.toml b/util/Cargo.toml index 362db33b2..d0e2e0ab7 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -26,7 +26,7 @@ crossbeam = "0.2" slab = { git = "https://github.com/arkpar/slab.git" } sha3 = { path = "sha3" } serde = "0.6.7" -clippy = "*" # Always newest, since we use nightly +clippy = "0.0.37" [dev-dependencies] json-tests = { path = "json-tests" } From 856c348e3eb39879761207bae2412e8b56cdacd2 Mon Sep 17 00:00:00 2001 From: debris Date: Wed, 27 Jan 2016 17:14:41 +0100 Subject: [PATCH 2/3] moved old rpc implementation to v1/ dir --- bin/src/main.rs | 2 +- rpc/src/lib.rs | 7 +------ rpc/src/{ => v1}/impls/eth.rs | 4 ++-- rpc/src/{ => v1}/impls/mod.rs | 0 rpc/src/{ => v1}/impls/net.rs | 2 +- rpc/src/{ => v1}/impls/web3.rs | 2 +- rpc/src/v1/mod.rs | 10 ++++++++++ rpc/src/{ => v1}/traits/eth.rs | 0 rpc/src/{ => v1}/traits/mod.rs | 0 rpc/src/{ => v1}/traits/net.rs | 0 rpc/src/{ => v1}/traits/web3.rs | 0 rpc/src/{ => v1}/types/block.rs | 0 rpc/src/{ => v1}/types/mod.rs | 0 13 files changed, 16 insertions(+), 11 deletions(-) rename rpc/src/{ => v1}/impls/eth.rs (98%) rename rpc/src/{ => v1}/impls/mod.rs (100%) rename rpc/src/{ => v1}/impls/net.rs (94%) rename rpc/src/{ => v1}/impls/web3.rs (95%) create mode 100644 rpc/src/v1/mod.rs rename rpc/src/{ => v1}/traits/eth.rs (100%) rename rpc/src/{ => v1}/traits/mod.rs (100%) rename rpc/src/{ => v1}/traits/net.rs (100%) rename rpc/src/{ => v1}/traits/web3.rs (100%) rename rpc/src/{ => v1}/types/block.rs (100%) rename rpc/src/{ => v1}/types/mod.rs (100%) diff --git a/bin/src/main.rs b/bin/src/main.rs index 402a0c7c1..712635652 100644 --- a/bin/src/main.rs +++ b/bin/src/main.rs @@ -50,7 +50,7 @@ fn setup_log(init: &String) { #[cfg(feature = "rpc")] fn setup_rpc_server(client: Arc) { - use rpc::*; + use rpc::v1::*; let mut server = HttpServer::new(1); server.add_delegate(Web3Client::new().to_delegate()); diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 816eeb4a4..7bc1d6987 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -17,12 +17,7 @@ macro_rules! rpcerr { () => (Err(Error::internal_error())) } -pub mod traits; -mod impls; -mod types; - -pub use self::traits::{Web3, Eth, EthFilter, Net}; -pub use self::impls::*; +pub mod v1; /// Http server. pub struct HttpServer { diff --git a/rpc/src/impls/eth.rs b/rpc/src/v1/impls/eth.rs similarity index 98% rename from rpc/src/impls/eth.rs rename to rpc/src/v1/impls/eth.rs index 91c05541a..46718601b 100644 --- a/rpc/src/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -6,8 +6,8 @@ use util::uint::*; use util::sha3::*; use ethcore::client::*; use ethcore::views::*; -use traits::{Eth, EthFilter}; -use types::Block; +use v1::traits::{Eth, EthFilter}; +use v1::types::Block; /// Eth rpc implementation. pub struct EthClient { diff --git a/rpc/src/impls/mod.rs b/rpc/src/v1/impls/mod.rs similarity index 100% rename from rpc/src/impls/mod.rs rename to rpc/src/v1/impls/mod.rs diff --git a/rpc/src/impls/net.rs b/rpc/src/v1/impls/net.rs similarity index 94% rename from rpc/src/impls/net.rs rename to rpc/src/v1/impls/net.rs index 20ed4d077..7bf9cb248 100644 --- a/rpc/src/impls/net.rs +++ b/rpc/src/v1/impls/net.rs @@ -1,6 +1,6 @@ //! Net rpc implementation. use jsonrpc_core::*; -use traits::Net; +use v1::traits::Net; /// Net rpc implementation. pub struct NetClient; diff --git a/rpc/src/impls/web3.rs b/rpc/src/v1/impls/web3.rs similarity index 95% rename from rpc/src/impls/web3.rs rename to rpc/src/v1/impls/web3.rs index 0188aa179..5117ebf16 100644 --- a/rpc/src/impls/web3.rs +++ b/rpc/src/v1/impls/web3.rs @@ -1,6 +1,6 @@ //! Web3 rpc implementation. use jsonrpc_core::*; -use traits::Web3; +use v1::traits::Web3; /// Web3 rpc implementation. pub struct Web3Client; diff --git a/rpc/src/v1/mod.rs b/rpc/src/v1/mod.rs new file mode 100644 index 000000000..a7da1a441 --- /dev/null +++ b/rpc/src/v1/mod.rs @@ -0,0 +1,10 @@ +//! Ethcore rpc v1. +//! +//! Compliant with ethereum rpc. + +pub mod traits; +mod impls; +mod types; + +pub use self::traits::{Web3, Eth, EthFilter, Net}; +pub use self::impls::*; diff --git a/rpc/src/traits/eth.rs b/rpc/src/v1/traits/eth.rs similarity index 100% rename from rpc/src/traits/eth.rs rename to rpc/src/v1/traits/eth.rs diff --git a/rpc/src/traits/mod.rs b/rpc/src/v1/traits/mod.rs similarity index 100% rename from rpc/src/traits/mod.rs rename to rpc/src/v1/traits/mod.rs diff --git a/rpc/src/traits/net.rs b/rpc/src/v1/traits/net.rs similarity index 100% rename from rpc/src/traits/net.rs rename to rpc/src/v1/traits/net.rs diff --git a/rpc/src/traits/web3.rs b/rpc/src/v1/traits/web3.rs similarity index 100% rename from rpc/src/traits/web3.rs rename to rpc/src/v1/traits/web3.rs diff --git a/rpc/src/types/block.rs b/rpc/src/v1/types/block.rs similarity index 100% rename from rpc/src/types/block.rs rename to rpc/src/v1/types/block.rs diff --git a/rpc/src/types/mod.rs b/rpc/src/v1/types/mod.rs similarity index 100% rename from rpc/src/types/mod.rs rename to rpc/src/v1/types/mod.rs From b93bf662b976de476d10b6061a43f5968f692dce Mon Sep 17 00:00:00 2001 From: debris Date: Wed, 27 Jan 2016 17:18:38 +0100 Subject: [PATCH 3/3] added Clippy to client executable, added missing docs --- bin/Cargo.toml | 1 + bin/src/main.rs | 8 ++++++-- rpc/Cargo.toml | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/Cargo.toml b/bin/Cargo.toml index ba258b586..7174ada14 100644 --- a/bin/Cargo.toml +++ b/bin/Cargo.toml @@ -15,6 +15,7 @@ ctrlc = "1.0" ethcore-util = { path = "../util" } ethcore-rpc = { path = "../rpc", optional = true } ethcore = { path = ".." } +clippy = "0.0.37" [features] rpc = ["ethcore-rpc"] diff --git a/bin/src/main.rs b/bin/src/main.rs index 712635652..190bab311 100644 --- a/bin/src/main.rs +++ b/bin/src/main.rs @@ -1,5 +1,9 @@ +//! Ethcore client application. + +#![warn(missing_docs)] #![feature(plugin)] #![plugin(docopt_macros)] +#![plugin(clippy)] extern crate docopt; extern crate rustc_serialize; extern crate ethcore_util as util; @@ -34,7 +38,7 @@ Options: -h --help Show this screen. "); -fn setup_log(init: &String) { +fn setup_log(init: &str) { let mut builder = LogBuilder::new(); builder.filter(None, LogLevelFilter::Info); @@ -52,7 +56,7 @@ fn setup_log(init: &String) { fn setup_rpc_server(client: Arc) { use rpc::v1::*; - let mut server = HttpServer::new(1); + let mut server = rpc::HttpServer::new(1); server.add_delegate(Web3Client::new().to_delegate()); server.add_delegate(EthClient::new(client.clone()).to_delegate()); server.add_delegate(EthFilterClient::new(client).to_delegate()); diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index ab7072c85..ee1c97f5f 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -3,7 +3,7 @@ description = "Ethcore jsonrpc" name = "ethcore-rpc" version = "0.1.0" license = "GPL-3.0" -authors = ["Marek Kotewicz