Merge branch 'master' of github.com:ethcore/parity
This commit is contained in:
commit
0bb5167fda
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -372,7 +372,7 @@ dependencies = [
|
||||
"clippy 0.0.64 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore-rpc 1.2.0",
|
||||
"ethcore-util 1.2.0",
|
||||
"hyper 0.9.0-mio (git+https://github.com/hyperium/hyper?branch=mio)",
|
||||
"hyper 0.9.1 (git+https://github.com/hyperium/hyper?branch=mio)",
|
||||
"jsonrpc-core 2.0.3 (git+https://github.com/tomusdrw/jsonrpc-core.git)",
|
||||
"jsonrpc-http-server 5.1.0 (git+https://github.com/tomusdrw/jsonrpc-http-server.git)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -507,8 +507,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.9.0-mio"
|
||||
source = "git+https://github.com/hyperium/hyper?branch=mio#fab6c4173063a10f2aacfe3872150537da3dcfdd"
|
||||
version = "0.9.1"
|
||||
source = "git+https://github.com/hyperium/hyper?branch=mio#8d121824231651cf22e7ad929e404032b28406df"
|
||||
dependencies = [
|
||||
"cookie 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"httparse 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -557,7 +557,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
[[package]]
|
||||
name = "json-ipc-server"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/NikVolf/json-ipc-server.git#bd987c75b5f23c35eb7e2b0bd8b30ba88f758338"
|
||||
source = "git+https://github.com/NikVolf/json-ipc-server.git#6515f27c7b41e5e62bc87ef4e0947b838a6c7d01"
|
||||
dependencies = [
|
||||
"bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"jsonrpc-core 2.0.3 (git+https://github.com/tomusdrw/jsonrpc-core.git)",
|
||||
@ -600,7 +600,7 @@ name = "jsonrpc-http-server"
|
||||
version = "5.1.0"
|
||||
source = "git+https://github.com/tomusdrw/jsonrpc-http-server.git#fafd6410284710b7e662fe7d76249cc496451f27"
|
||||
dependencies = [
|
||||
"hyper 0.9.0-mio (git+https://github.com/hyperium/hyper?branch=mio)",
|
||||
"hyper 0.9.1 (git+https://github.com/hyperium/hyper?branch=mio)",
|
||||
"jsonrpc-core 2.0.3 (git+https://github.com/tomusdrw/jsonrpc-core.git)",
|
||||
"unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -24,7 +24,7 @@ use engine::*;
|
||||
use evm::{Schedule, Factory};
|
||||
use ethjson;
|
||||
|
||||
/// BasicAuthority params.
|
||||
/// `BasicAuthority` params.
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct BasicAuthorityParams {
|
||||
/// Gas limit divisor.
|
||||
@ -45,7 +45,7 @@ impl From<ethjson::spec::BasicAuthorityParams> for BasicAuthorityParams {
|
||||
}
|
||||
}
|
||||
|
||||
/// Engine using BasicAuthority proof-of-work consensus algorithm, suitable for Ethereum
|
||||
/// Engine using `BasicAuthority` proof-of-work consensus algorithm, suitable for Ethereum
|
||||
/// mainnet chains in the Olympic, Frontier and Homestead eras.
|
||||
pub struct BasicAuthority {
|
||||
params: CommonParams,
|
||||
@ -192,7 +192,7 @@ impl Header {
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new test chain spec with BasicAuthority consensus engine.
|
||||
/// Create a new test chain spec with `BasicAuthority` consensus engine.
|
||||
pub fn new_test_authority() -> Spec { Spec::load(include_bytes!("../res/test_authority.json")) }
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -42,7 +42,7 @@ use env_info::EnvInfo;
|
||||
use executive::{Executive, Executed, TransactOptions, contract_address};
|
||||
use receipt::LocalizedReceipt;
|
||||
pub use blockchain::CacheSize as BlockChainCacheSize;
|
||||
use trace::{TraceDB, ImportRequest as TraceImportRequest, LocalizedTrace, Database as TraceDatabase, Filter as TracedbFilter};
|
||||
use trace::{TraceDB, ImportRequest as TraceImportRequest, LocalizedTrace, Database as TraceDatabase};
|
||||
use trace;
|
||||
|
||||
/// General block status
|
||||
|
@ -166,9 +166,9 @@ impl Miner {
|
||||
trace!(target: "miner", "prepare_sealing: block has transaction - attempting internal seal.");
|
||||
// block with transactions - see if we can seal immediately.
|
||||
let a = self.accounts.read().unwrap();
|
||||
let s = chain.generate_seal(block.block(), match a.deref() {
|
||||
&Some(ref x) => Some(x.deref() as &AccountProvider),
|
||||
&None => None,
|
||||
let s = chain.generate_seal(block.block(), match *a.deref() {
|
||||
Some(ref x) => Some(x.deref() as &AccountProvider),
|
||||
None => None,
|
||||
});
|
||||
if let Some(seal) = s {
|
||||
trace!(target: "miner", "prepare_sealing: managed internal seal. importing...");
|
||||
@ -183,7 +183,7 @@ impl Miner {
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
trace!(target: "miner", "prepare_sealing: unable to generate seal internally");
|
||||
trace!(target: "miner", "prepare_sealing: unable to generate seal internally");
|
||||
}
|
||||
}
|
||||
if sealing_work.peek_last_ref().map_or(true, |pb| pb.block().fields().header.hash() != block.block().fields().header.hash()) {
|
||||
|
@ -215,7 +215,7 @@ fn execute_client(conf: Configuration) {
|
||||
}
|
||||
|
||||
fn flush_stdout() {
|
||||
::std::io::stdout().flush().ok().expect("stdout is flushable; qed");
|
||||
::std::io::stdout().flush().expect("stdout is flushable; qed");
|
||||
}
|
||||
|
||||
fn execute_account_cli(conf: Configuration) {
|
||||
|
@ -109,7 +109,7 @@ fn setup_rpc_server(apis: Vec<&str>, deps: &Arc<Dependencies>) -> Server {
|
||||
server.add_delegate(PersonalClient::new(&deps.secret_store).to_delegate())
|
||||
},
|
||||
"ethcore" => {
|
||||
// not adding to modules, since `ethcore` is not supported in geth
|
||||
modules.insert("ethcore".to_owned(), "1.0".to_owned());
|
||||
server.add_delegate(EthcoreClient::new(&deps.miner, deps.logger.clone(), deps.settings.clone()).to_delegate())
|
||||
},
|
||||
"traces" => {
|
||||
|
@ -22,23 +22,41 @@ use v1::traits::Rpc;
|
||||
/// RPC generic methods implementation.
|
||||
pub struct RpcClient {
|
||||
modules: BTreeMap<String, String>,
|
||||
valid_apis: Vec<String>,
|
||||
}
|
||||
|
||||
impl RpcClient {
|
||||
/// Creates new `RpcClient`.
|
||||
pub fn new(modules: BTreeMap<String, String>) -> Self {
|
||||
// geth 1.3.6 fails upon receiving unknown api
|
||||
let valid_apis = vec!["web3", "eth", "net", "personal", "rpc"];
|
||||
|
||||
RpcClient {
|
||||
modules: modules
|
||||
modules: modules,
|
||||
valid_apis: valid_apis.into_iter().map(|x| x.to_owned()).collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Rpc for RpcClient {
|
||||
fn rpc_modules(&self, _: Params) -> Result<Value, Error> {
|
||||
let modules = self.modules.iter()
|
||||
.fold(BTreeMap::new(), |mut map, (k, v)| {
|
||||
map.insert(k.to_owned(), Value::String(v.to_owned()));
|
||||
map
|
||||
});
|
||||
Ok(Value::Object(modules))
|
||||
}
|
||||
|
||||
fn modules(&self, _: Params) -> Result<Value, Error> {
|
||||
let modules = self.modules.iter().fold(BTreeMap::new(), |mut map, (k, v)| {
|
||||
map.insert(k.to_owned(), Value::String(v.to_owned()));
|
||||
map
|
||||
});
|
||||
let modules = self.modules.iter()
|
||||
.filter(|&(k, _v)| {
|
||||
self.valid_apis.contains(k)
|
||||
})
|
||||
.fold(BTreeMap::new(), |mut map, (k, v)| {
|
||||
map.insert(k.to_owned(), Value::String(v.to_owned()));
|
||||
map
|
||||
});
|
||||
Ok(Value::Object(modules))
|
||||
}
|
||||
}
|
||||
|
@ -27,3 +27,5 @@ mod web3;
|
||||
mod personal;
|
||||
#[cfg(test)]
|
||||
mod ethcore;
|
||||
#[cfg(test)]
|
||||
mod rpc;
|
||||
|
@ -22,17 +22,31 @@ use v1::{Rpc, RpcClient};
|
||||
fn rpc_client() -> RpcClient {
|
||||
let mut modules = BTreeMap::new();
|
||||
modules.insert("rpc".to_owned(), "1.0".to_owned());
|
||||
modules.insert("web3".to_owned(), "1.0".to_owned());
|
||||
modules.insert("ethcore".to_owned(), "1.0".to_owned());
|
||||
RpcClient::new(modules)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn modules() {
|
||||
let rpc = rpc_client().to_delegate();
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(rpc);
|
||||
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "modules", "params": [], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"rpc":"1.0","web3":"1.0"},"id":1}"#;
|
||||
|
||||
assert_eq!(io.handle_request(request), Some(response.to_owned()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rpc_modules() {
|
||||
let rpc = rpc_client().to_delegate();
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(rpc);
|
||||
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "modules", "params": [], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"eth": "1.0"},"id":1}"#;
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "rpc_modules", "params": [], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"ethcore":"1.0","rpc":"1.0","web3":"1.0"},"id":1}"#;
|
||||
|
||||
assert_eq!(io.handle_request(request), Some(response.to_owned()));
|
||||
}
|
||||
|
@ -22,16 +22,19 @@ use jsonrpc_core::*;
|
||||
/// RPC Interface.
|
||||
pub trait Rpc: Sized + Send + Sync + 'static {
|
||||
|
||||
/// Returns supported modules.
|
||||
/// Returns supported modules for Geth 1.3.6
|
||||
fn modules(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
|
||||
/// Returns supported modules for Geth 1.4.0
|
||||
fn rpc_modules(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
|
||||
/// Should be used to convert object to io delegate.
|
||||
fn to_delegate(self) -> IoDelegate<Self> {
|
||||
let mut delegate = IoDelegate::new(Arc::new(self));
|
||||
// Geth 1.3.6 compatibility
|
||||
delegate.add_method("modules", Rpc::modules);
|
||||
// Geth 1.4.0 compatibility
|
||||
delegate.add_method("rpc_modules", Rpc::modules);
|
||||
delegate.add_method("rpc_modules", Rpc::rpc_modules);
|
||||
delegate
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user