Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #244 from ethcore/clippy
Browse files Browse the repository at this point in the history
clippy, missing docs, renaming etc.
  • Loading branch information
arkpar committed Jan 27, 2016
2 parents ec42dd6 + b93bf66 commit 10dd07f
Show file tree
Hide file tree
Showing 20 changed files with 45 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
11 changes: 7 additions & 4 deletions bin/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
//! Ethcore client application.

#![warn(missing_docs)]
#![feature(plugin)]
#![plugin(docopt_macros)]
// required for serde, move it to a separate library
#![plugin(clippy)]
extern crate docopt;
extern crate rustc_serialize;
extern crate ethcore_util as util;
Expand Down Expand Up @@ -35,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);

Expand All @@ -51,9 +54,9 @@ fn setup_log(init: &String) {

#[cfg(feature = "rpc")]
fn setup_rpc_server(client: Arc<Client>) {
use rpc::*;
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());
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description = "Ethcore jsonrpc"
name = "ethcore-rpc"
version = "0.1.0"
license = "GPL-3.0"
authors = ["Marek Kotewicz <marek.kotewicz@gmail.com"]
authors = ["Ethcore <admin@ethcore.io"]

[lib]

Expand All @@ -15,4 +15,5 @@ jsonrpc-core = "1.1"
jsonrpc-http-server = "1.1"
ethcore-util = { path = "../util" }
ethcore = { path = ".." }
clippy = "0.0.37"

15 changes: 8 additions & 7 deletions rpc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,30 +17,29 @@ 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 {
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(),
threads: threads
}
}

/// Add io delegate.
pub fn add_delegate<D>(&mut self, delegate: IoDelegate<D>) 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)
Expand Down
9 changes: 7 additions & 2 deletions rpc/src/impls/eth.rs → rpc/src/v1/impls/eth.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
//! Eth rpc implementation.
use std::sync::Arc;
use jsonrpc_core::*;
use util::hash::*;
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 {
client: Arc<Client>,
}

impl EthClient {
/// Creates new EthClient.
pub fn new(client: Arc<Client>) -> Self {
EthClient {
client: client
Expand Down Expand Up @@ -100,11 +103,13 @@ impl Eth for EthClient {
}
}

/// Eth filter rpc implementation.
pub struct EthFilterClient {
client: Arc<Client>
}

impl EthFilterClient {
/// Creates new Eth filter client.
pub fn new(client: Arc<Client>) -> Self {
EthFilterClient {
client: client
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion rpc/src/impls/net.rs → rpc/src/v1/impls/net.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
//! Net rpc implementation.
use jsonrpc_core::*;
use traits::Net;
use v1::traits::Net;

/// Net rpc implementation.
pub struct NetClient;

impl NetClient {
/// Creates new NetClient.
pub fn new() -> Self { NetClient }
}

Expand Down
5 changes: 4 additions & 1 deletion rpc/src/impls/web3.rs → rpc/src/v1/impls/web3.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
//! Web3 rpc implementation.
use jsonrpc_core::*;
use traits::Web3;
use v1::traits::Web3;

/// Web3 rpc implementation.
pub struct Web3Client;

impl Web3Client {
/// Creates new Web3Client.
pub fn new() -> Self { Web3Client }
}

Expand Down
10 changes: 10 additions & 0 deletions rpc/src/v1/mod.rs
Original file line number Diff line number Diff line change
@@ -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::*;
1 change: 1 addition & 0 deletions rpc/src/traits/eth.rs → rpc/src/v1/traits/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

0 comments on commit 10dd07f

Please sign in to comment.