Merge pull request #1208 from ethcore/switchrpcns
Switch RPC namespace form ethcore_ to trace_
This commit is contained in:
commit
a460813788
@ -153,10 +153,10 @@ pub fn setup_rpc<T: Extendable>(server: T, deps: Arc<Dependencies>, apis: ApiSet
|
||||
}
|
||||
},
|
||||
Api::Ethcore => {
|
||||
server.add_delegate(EthcoreClient::new(&deps.client, &deps.miner, deps.logger.clone(), deps.settings.clone()).to_delegate())
|
||||
server.add_delegate(EthcoreClient::new(&deps.miner, deps.logger.clone(), deps.settings.clone()).to_delegate())
|
||||
},
|
||||
Api::Traces => {
|
||||
server.add_delegate(TracesClient::new(&deps.client).to_delegate())
|
||||
server.add_delegate(TracesClient::new(&deps.client, &deps.miner).to_delegate())
|
||||
},
|
||||
Api::Rpc => {
|
||||
let modules = to_modules(&apis);
|
||||
|
@ -15,151 +15,39 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Ethcore-specific rpc implementation.
|
||||
use util::{U256, Address, RotatingLogger, FixedHash, Uint};
|
||||
use util::{U256, Address, RotatingLogger, FixedHash};
|
||||
use util::network_settings::NetworkSettings;
|
||||
use util::misc::version_data;
|
||||
use std::sync::{Arc, Weak};
|
||||
use std::ops::Deref;
|
||||
use std::collections::BTreeMap;
|
||||
use jsonrpc_core::*;
|
||||
use serde;
|
||||
use ethcore::miner::MinerService;
|
||||
use ethcore::state_diff::StateDiff;
|
||||
use ethcore::account_diff::{Diff, Existance};
|
||||
use ethcore::transaction::{Transaction as EthTransaction, SignedTransaction, Action};
|
||||
use ethcore::client::{BlockChainClient, CallAnalytics};
|
||||
use ethcore::trace::VMTrace;
|
||||
use ethcore::client::{BlockChainClient};
|
||||
use v1::traits::Ethcore;
|
||||
use v1::types::{Bytes, CallRequest};
|
||||
use v1::types::{Bytes};
|
||||
|
||||
/// Ethcore implementation.
|
||||
pub struct EthcoreClient<C, M> where
|
||||
C: BlockChainClient,
|
||||
pub struct EthcoreClient<M> where
|
||||
M: MinerService {
|
||||
|
||||
client: Weak<C>,
|
||||
miner: Weak<M>,
|
||||
logger: Arc<RotatingLogger>,
|
||||
settings: Arc<NetworkSettings>,
|
||||
}
|
||||
|
||||
impl<C, M> EthcoreClient<C, M> where C: BlockChainClient, M: MinerService {
|
||||
impl<M> EthcoreClient<M> where M: MinerService {
|
||||
/// Creates new `EthcoreClient`.
|
||||
pub fn new(client: &Arc<C>, miner: &Arc<M>, logger: Arc<RotatingLogger>, settings: Arc<NetworkSettings>) -> Self {
|
||||
pub fn new(miner: &Arc<M>, logger: Arc<RotatingLogger>, settings: Arc<NetworkSettings>) -> Self {
|
||||
EthcoreClient {
|
||||
client: Arc::downgrade(client),
|
||||
miner: Arc::downgrade(miner),
|
||||
logger: logger,
|
||||
settings: settings,
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: share with eth.rs
|
||||
fn sign_call(&self, request: CallRequest) -> Result<SignedTransaction, Error> {
|
||||
let client = take_weak!(self.client);
|
||||
let miner = take_weak!(self.miner);
|
||||
let from = request.from.unwrap_or(Address::zero());
|
||||
Ok(EthTransaction {
|
||||
nonce: request.nonce.unwrap_or_else(|| client.latest_nonce(&from)),
|
||||
action: request.to.map_or(Action::Create, Action::Call),
|
||||
gas: request.gas.unwrap_or(U256::from(50_000_000)),
|
||||
gas_price: request.gas_price.unwrap_or_else(|| miner.sensible_gas_price()),
|
||||
value: request.value.unwrap_or_else(U256::zero),
|
||||
data: request.data.map_or_else(Vec::new, |d| d.to_vec())
|
||||
}.fake_sign(from))
|
||||
}
|
||||
}
|
||||
|
||||
fn vm_trace_to_object(t: &VMTrace) -> Value {
|
||||
let mut ret = BTreeMap::new();
|
||||
ret.insert("code".to_owned(), to_value(&t.code).unwrap());
|
||||
|
||||
let mut subs = t.subs.iter();
|
||||
let mut next_sub = subs.next();
|
||||
|
||||
let ops = t.operations
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, op)| {
|
||||
let mut m = map![
|
||||
"pc".to_owned() => to_value(&op.pc).unwrap(),
|
||||
"cost".to_owned() => match op.gas_cost <= U256::from(!0u64) {
|
||||
true => to_value(&op.gas_cost.low_u64()),
|
||||
false => to_value(&op.gas_cost),
|
||||
}.unwrap()
|
||||
];
|
||||
if let Some(ref ex) = op.executed {
|
||||
let mut em = map![
|
||||
"used".to_owned() => to_value(&ex.gas_used.low_u64()).unwrap(),
|
||||
"push".to_owned() => to_value(&ex.stack_push).unwrap()
|
||||
];
|
||||
if let Some(ref md) = ex.mem_diff {
|
||||
em.insert("mem".to_owned(), Value::Object(map![
|
||||
"off".to_owned() => to_value(&md.offset).unwrap(),
|
||||
"data".to_owned() => to_value(&md.data).unwrap()
|
||||
]));
|
||||
}
|
||||
if let Some(ref sd) = ex.store_diff {
|
||||
em.insert("store".to_owned(), Value::Object(map![
|
||||
"key".to_owned() => to_value(&sd.location).unwrap(),
|
||||
"val".to_owned() => to_value(&sd.value).unwrap()
|
||||
]));
|
||||
}
|
||||
m.insert("ex".to_owned(), Value::Object(em));
|
||||
}
|
||||
if next_sub.is_some() && next_sub.unwrap().parent_step == i {
|
||||
m.insert("sub".to_owned(), vm_trace_to_object(next_sub.unwrap()));
|
||||
next_sub = subs.next();
|
||||
}
|
||||
Value::Object(m)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
ret.insert("ops".to_owned(), Value::Array(ops));
|
||||
Value::Object(ret)
|
||||
}
|
||||
|
||||
fn diff_to_object<T>(d: &Diff<T>) -> Value where T: serde::Serialize + Eq {
|
||||
let mut ret = BTreeMap::new();
|
||||
match *d {
|
||||
Diff::Same => {
|
||||
ret.insert("diff".to_owned(), Value::String("=".to_owned()));
|
||||
}
|
||||
Diff::Born(ref x) => {
|
||||
ret.insert("diff".to_owned(), Value::String("+".to_owned()));
|
||||
ret.insert("+".to_owned(), to_value(x).unwrap());
|
||||
}
|
||||
Diff::Died(ref x) => {
|
||||
ret.insert("diff".to_owned(), Value::String("-".to_owned()));
|
||||
ret.insert("-".to_owned(), to_value(x).unwrap());
|
||||
}
|
||||
Diff::Changed(ref from, ref to) => {
|
||||
ret.insert("diff".to_owned(), Value::String("*".to_owned()));
|
||||
ret.insert("-".to_owned(), to_value(from).unwrap());
|
||||
ret.insert("+".to_owned(), to_value(to).unwrap());
|
||||
}
|
||||
};
|
||||
Value::Object(ret)
|
||||
}
|
||||
|
||||
fn state_diff_to_object(t: &StateDiff) -> Value {
|
||||
Value::Object(t.iter().map(|(address, account)| {
|
||||
(address.hex(), Value::Object(map![
|
||||
"existance".to_owned() => Value::String(match account.existance() {
|
||||
Existance::Born => "+",
|
||||
Existance::Alive => ".",
|
||||
Existance::Died => "-",
|
||||
}.to_owned()),
|
||||
"balance".to_owned() => diff_to_object(&account.balance),
|
||||
"nonce".to_owned() => diff_to_object(&account.nonce),
|
||||
"code".to_owned() => diff_to_object(&account.code),
|
||||
"storage".to_owned() => Value::Object(account.storage.iter().map(|(key, val)| {
|
||||
(key.hex(), diff_to_object(&val))
|
||||
}).collect::<BTreeMap<_, _>>())
|
||||
]))
|
||||
}).collect::<BTreeMap<_, _>>())
|
||||
}
|
||||
|
||||
impl<C, M> Ethcore for EthcoreClient<C, M> where C: BlockChainClient + 'static, M: MinerService + 'static {
|
||||
impl<M> Ethcore for EthcoreClient<M> where M: MinerService + 'static {
|
||||
|
||||
fn set_min_gas_price(&self, params: Params) -> Result<Value, Error> {
|
||||
from_params::<(U256,)>(params).and_then(|(gas_price,)| {
|
||||
@ -249,34 +137,4 @@ impl<C, M> Ethcore for EthcoreClient<C, M> where C: BlockChainClient + 'static,
|
||||
let version = version_data();
|
||||
to_value(&Bytes::new(version))
|
||||
}
|
||||
|
||||
fn vm_trace_call(&self, params: Params) -> Result<Value, Error> {
|
||||
trace!(target: "jsonrpc", "vm_trace_call: {:?}", params);
|
||||
from_params(params)
|
||||
.and_then(|(request,)| {
|
||||
let signed = try!(self.sign_call(request));
|
||||
let r = take_weak!(self.client).call(&signed, CallAnalytics{ vm_tracing: true, state_diffing: false });
|
||||
if let Ok(executed) = r {
|
||||
if let Some(vm_trace) = executed.vm_trace {
|
||||
return Ok(vm_trace_to_object(&vm_trace));
|
||||
}
|
||||
}
|
||||
Ok(Value::Null)
|
||||
})
|
||||
}
|
||||
|
||||
fn state_diff_call(&self, params: Params) -> Result<Value, Error> {
|
||||
trace!(target: "jsonrpc", "state_diff_call: {:?}", params);
|
||||
from_params(params)
|
||||
.and_then(|(request,)| {
|
||||
let signed = try!(self.sign_call(request));
|
||||
let r = take_weak!(self.client).call(&signed, CallAnalytics{ vm_tracing: false, state_diffing: true });
|
||||
if let Ok(executed) = r {
|
||||
if let Some(state_diff) = executed.state_diff {
|
||||
return Ok(state_diff_to_object(&state_diff));
|
||||
}
|
||||
}
|
||||
Ok(Value::Null)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -18,26 +18,139 @@
|
||||
|
||||
use std::sync::{Weak, Arc};
|
||||
use jsonrpc_core::*;
|
||||
use util::H256;
|
||||
use ethcore::client::{BlockChainClient, TransactionID, TraceId};
|
||||
use std::collections::BTreeMap;
|
||||
use util::{H256, U256, FixedHash, Uint};
|
||||
use serde;
|
||||
use ethcore::client::{BlockChainClient, CallAnalytics, TransactionID, TraceId};
|
||||
use ethcore::trace::VMTrace;
|
||||
use ethcore::miner::MinerService;
|
||||
use ethcore::state_diff::StateDiff;
|
||||
use ethcore::account_diff::{Diff, Existance};
|
||||
use ethcore::transaction::{Transaction as EthTransaction, SignedTransaction, Action};
|
||||
use v1::traits::Traces;
|
||||
use v1::types::{TraceFilter, Trace, BlockNumber, Index};
|
||||
use v1::types::{TraceFilter, Trace, BlockNumber, Index, CallRequest};
|
||||
|
||||
/// Traces api implementation.
|
||||
pub struct TracesClient<C> where C: BlockChainClient {
|
||||
pub struct TracesClient<C, M> where C: BlockChainClient, M: MinerService {
|
||||
client: Weak<C>,
|
||||
miner: Weak<M>,
|
||||
}
|
||||
|
||||
impl<C> TracesClient<C> where C: BlockChainClient {
|
||||
impl<C, M> TracesClient<C, M> where C: BlockChainClient, M: MinerService {
|
||||
/// Creates new Traces client.
|
||||
pub fn new(client: &Arc<C>) -> Self {
|
||||
pub fn new(client: &Arc<C>, miner: &Arc<M>) -> Self {
|
||||
TracesClient {
|
||||
client: Arc::downgrade(client),
|
||||
miner: Arc::downgrade(miner),
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: share with eth.rs
|
||||
fn sign_call(&self, request: CallRequest) -> Result<SignedTransaction, Error> {
|
||||
let client = take_weak!(self.client);
|
||||
let miner = take_weak!(self.miner);
|
||||
let from = request.from.unwrap_or(0.into());
|
||||
Ok(EthTransaction {
|
||||
nonce: request.nonce.unwrap_or_else(|| client.latest_nonce(&from)),
|
||||
action: request.to.map_or(Action::Create, Action::Call),
|
||||
gas: request.gas.unwrap_or(50_000_000.into()),
|
||||
gas_price: request.gas_price.unwrap_or_else(|| miner.sensible_gas_price()),
|
||||
value: request.value.unwrap_or(0.into()),
|
||||
data: request.data.map_or_else(Vec::new, |d| d.to_vec())
|
||||
}.fake_sign(from))
|
||||
}
|
||||
}
|
||||
|
||||
impl<C> Traces for TracesClient<C> where C: BlockChainClient + 'static {
|
||||
fn vm_trace_to_object(t: &VMTrace) -> Value {
|
||||
let mut ret = BTreeMap::new();
|
||||
ret.insert("code".to_owned(), to_value(&t.code).unwrap());
|
||||
|
||||
let mut subs = t.subs.iter();
|
||||
let mut next_sub = subs.next();
|
||||
|
||||
let ops = t.operations
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, op)| {
|
||||
let mut m = map![
|
||||
"pc".to_owned() => to_value(&op.pc).unwrap(),
|
||||
"cost".to_owned() => match op.gas_cost <= U256::from(!0u64) {
|
||||
true => to_value(&op.gas_cost.low_u64()),
|
||||
false => to_value(&op.gas_cost),
|
||||
}.unwrap()
|
||||
];
|
||||
if let Some(ref ex) = op.executed {
|
||||
let mut em = map![
|
||||
"used".to_owned() => to_value(&ex.gas_used.low_u64()).unwrap(),
|
||||
"push".to_owned() => to_value(&ex.stack_push).unwrap()
|
||||
];
|
||||
if let Some(ref md) = ex.mem_diff {
|
||||
em.insert("mem".to_owned(), Value::Object(map![
|
||||
"off".to_owned() => to_value(&md.offset).unwrap(),
|
||||
"data".to_owned() => to_value(&md.data).unwrap()
|
||||
]));
|
||||
}
|
||||
if let Some(ref sd) = ex.store_diff {
|
||||
em.insert("store".to_owned(), Value::Object(map![
|
||||
"key".to_owned() => to_value(&sd.location).unwrap(),
|
||||
"val".to_owned() => to_value(&sd.value).unwrap()
|
||||
]));
|
||||
}
|
||||
m.insert("ex".to_owned(), Value::Object(em));
|
||||
}
|
||||
if next_sub.is_some() && next_sub.unwrap().parent_step == i {
|
||||
m.insert("sub".to_owned(), vm_trace_to_object(next_sub.unwrap()));
|
||||
next_sub = subs.next();
|
||||
}
|
||||
Value::Object(m)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
ret.insert("ops".to_owned(), Value::Array(ops));
|
||||
Value::Object(ret)
|
||||
}
|
||||
|
||||
fn diff_to_object<T>(d: &Diff<T>) -> Value where T: serde::Serialize + Eq {
|
||||
let mut ret = BTreeMap::new();
|
||||
match *d {
|
||||
Diff::Same => {
|
||||
ret.insert("diff".to_owned(), Value::String("=".to_owned()));
|
||||
}
|
||||
Diff::Born(ref x) => {
|
||||
ret.insert("diff".to_owned(), Value::String("+".to_owned()));
|
||||
ret.insert("+".to_owned(), to_value(x).unwrap());
|
||||
}
|
||||
Diff::Died(ref x) => {
|
||||
ret.insert("diff".to_owned(), Value::String("-".to_owned()));
|
||||
ret.insert("-".to_owned(), to_value(x).unwrap());
|
||||
}
|
||||
Diff::Changed(ref from, ref to) => {
|
||||
ret.insert("diff".to_owned(), Value::String("*".to_owned()));
|
||||
ret.insert("-".to_owned(), to_value(from).unwrap());
|
||||
ret.insert("+".to_owned(), to_value(to).unwrap());
|
||||
}
|
||||
};
|
||||
Value::Object(ret)
|
||||
}
|
||||
|
||||
fn state_diff_to_object(t: &StateDiff) -> Value {
|
||||
Value::Object(t.iter().map(|(address, account)| {
|
||||
(address.hex(), Value::Object(map![
|
||||
"existance".to_owned() => Value::String(match account.existance() {
|
||||
Existance::Born => "+",
|
||||
Existance::Alive => ".",
|
||||
Existance::Died => "-",
|
||||
}.to_owned()),
|
||||
"balance".to_owned() => diff_to_object(&account.balance),
|
||||
"nonce".to_owned() => diff_to_object(&account.nonce),
|
||||
"code".to_owned() => diff_to_object(&account.code),
|
||||
"storage".to_owned() => Value::Object(account.storage.iter().map(|(key, val)| {
|
||||
(key.hex(), diff_to_object(&val))
|
||||
}).collect::<BTreeMap<_, _>>())
|
||||
]))
|
||||
}).collect::<BTreeMap<_, _>>())
|
||||
}
|
||||
|
||||
impl<C, M> Traces for TracesClient<C, M> where C: BlockChainClient + 'static, M: MinerService + 'static {
|
||||
fn filter(&self, params: Params) -> Result<Value, Error> {
|
||||
from_params::<(TraceFilter,)>(params)
|
||||
.and_then(|(filter, )| {
|
||||
@ -81,4 +194,34 @@ impl<C> Traces for TracesClient<C> where C: BlockChainClient + 'static {
|
||||
to_value(&trace)
|
||||
})
|
||||
}
|
||||
|
||||
fn vm_trace_call(&self, params: Params) -> Result<Value, Error> {
|
||||
trace!(target: "jsonrpc", "vm_trace_call: {:?}", params);
|
||||
from_params(params)
|
||||
.and_then(|(request,)| {
|
||||
let signed = try!(self.sign_call(request));
|
||||
let r = take_weak!(self.client).call(&signed, CallAnalytics{ vm_tracing: true, state_diffing: false });
|
||||
if let Ok(executed) = r {
|
||||
if let Some(vm_trace) = executed.vm_trace {
|
||||
return Ok(vm_trace_to_object(&vm_trace));
|
||||
}
|
||||
}
|
||||
Ok(Value::Null)
|
||||
})
|
||||
}
|
||||
|
||||
fn state_diff_call(&self, params: Params) -> Result<Value, Error> {
|
||||
trace!(target: "jsonrpc", "state_diff_call: {:?}", params);
|
||||
from_params(params)
|
||||
.and_then(|(request,)| {
|
||||
let signed = try!(self.sign_call(request));
|
||||
let r = take_weak!(self.client).call(&signed, CallAnalytics{ vm_tracing: false, state_diffing: true });
|
||||
if let Ok(executed) = r {
|
||||
if let Some(state_diff) = executed.state_diff {
|
||||
return Ok(state_diff_to_object(&state_diff));
|
||||
}
|
||||
}
|
||||
Ok(Value::Null)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ use std::sync::Arc;
|
||||
use std::str::FromStr;
|
||||
use jsonrpc_core::IoHandler;
|
||||
use v1::{Ethcore, EthcoreClient};
|
||||
use ethcore::client::{TestBlockChainClient};
|
||||
use ethcore::miner::MinerService;
|
||||
use v1::tests::helpers::TestMinerService;
|
||||
use util::numbers::*;
|
||||
@ -26,11 +25,6 @@ use rustc_serialize::hex::FromHex;
|
||||
use util::log::RotatingLogger;
|
||||
use util::network_settings::NetworkSettings;
|
||||
|
||||
fn blockchain_client() -> Arc<TestBlockChainClient> {
|
||||
let client = TestBlockChainClient::new();
|
||||
Arc::new(client)
|
||||
}
|
||||
|
||||
fn miner_service() -> Arc<TestMinerService> {
|
||||
Arc::new(TestMinerService::default())
|
||||
}
|
||||
@ -51,15 +45,14 @@ fn settings() -> Arc<NetworkSettings> {
|
||||
})
|
||||
}
|
||||
|
||||
fn ethcore_client(client: &Arc<TestBlockChainClient>, miner: &Arc<TestMinerService>) -> EthcoreClient<TestBlockChainClient, TestMinerService> {
|
||||
EthcoreClient::new(&client, &miner, logger(), settings())
|
||||
fn ethcore_client(miner: &Arc<TestMinerService>) -> EthcoreClient<TestMinerService> {
|
||||
EthcoreClient::new(&miner, logger(), settings())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rpc_ethcore_extra_data() {
|
||||
let miner = miner_service();
|
||||
let client = blockchain_client();
|
||||
let ethcore = ethcore_client(&client, &miner).to_delegate();
|
||||
let ethcore = ethcore_client(&miner).to_delegate();
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(ethcore);
|
||||
|
||||
@ -75,8 +68,7 @@ fn rpc_ethcore_default_extra_data() {
|
||||
use util::ToPretty;
|
||||
|
||||
let miner = miner_service();
|
||||
let client = blockchain_client();
|
||||
let ethcore = ethcore_client(&client, &miner).to_delegate();
|
||||
let ethcore = ethcore_client(&miner).to_delegate();
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(ethcore);
|
||||
|
||||
@ -89,8 +81,7 @@ fn rpc_ethcore_default_extra_data() {
|
||||
#[test]
|
||||
fn rpc_ethcore_gas_floor_target() {
|
||||
let miner = miner_service();
|
||||
let client = blockchain_client();
|
||||
let ethcore = ethcore_client(&client, &miner).to_delegate();
|
||||
let ethcore = ethcore_client(&miner).to_delegate();
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(ethcore);
|
||||
|
||||
@ -103,8 +94,7 @@ fn rpc_ethcore_gas_floor_target() {
|
||||
#[test]
|
||||
fn rpc_ethcore_min_gas_price() {
|
||||
let miner = miner_service();
|
||||
let client = blockchain_client();
|
||||
let ethcore = ethcore_client(&client, &miner).to_delegate();
|
||||
let ethcore = ethcore_client(&miner).to_delegate();
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(ethcore);
|
||||
|
||||
@ -117,8 +107,7 @@ fn rpc_ethcore_min_gas_price() {
|
||||
#[test]
|
||||
fn rpc_ethcore_set_min_gas_price() {
|
||||
let miner = miner_service();
|
||||
let client = blockchain_client();
|
||||
let ethcore = ethcore_client(&client, &miner).to_delegate();
|
||||
let ethcore = ethcore_client(&miner).to_delegate();
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(ethcore);
|
||||
|
||||
@ -132,8 +121,7 @@ fn rpc_ethcore_set_min_gas_price() {
|
||||
#[test]
|
||||
fn rpc_ethcore_set_gas_floor_target() {
|
||||
let miner = miner_service();
|
||||
let client = blockchain_client();
|
||||
let ethcore = ethcore_client(&client, &miner).to_delegate();
|
||||
let ethcore = ethcore_client(&miner).to_delegate();
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(ethcore);
|
||||
|
||||
@ -147,8 +135,7 @@ fn rpc_ethcore_set_gas_floor_target() {
|
||||
#[test]
|
||||
fn rpc_ethcore_set_extra_data() {
|
||||
let miner = miner_service();
|
||||
let client = blockchain_client();
|
||||
let ethcore = ethcore_client(&client, &miner).to_delegate();
|
||||
let ethcore = ethcore_client(&miner).to_delegate();
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(ethcore);
|
||||
|
||||
@ -162,8 +149,7 @@ fn rpc_ethcore_set_extra_data() {
|
||||
#[test]
|
||||
fn rpc_ethcore_set_author() {
|
||||
let miner = miner_service();
|
||||
let client = blockchain_client();
|
||||
let ethcore = ethcore_client(&client, &miner).to_delegate();
|
||||
let ethcore = ethcore_client(&miner).to_delegate();
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(ethcore);
|
||||
|
||||
@ -177,11 +163,10 @@ fn rpc_ethcore_set_author() {
|
||||
#[test]
|
||||
fn rpc_ethcore_dev_logs() {
|
||||
let miner = miner_service();
|
||||
let client = blockchain_client();
|
||||
let logger = logger();
|
||||
logger.append("a".to_owned());
|
||||
logger.append("b".to_owned());
|
||||
let ethcore = EthcoreClient::new(&client, &miner, logger.clone(), settings()).to_delegate();
|
||||
let ethcore = EthcoreClient::new(&miner, logger.clone(), settings()).to_delegate();
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(ethcore);
|
||||
|
||||
@ -194,8 +179,7 @@ fn rpc_ethcore_dev_logs() {
|
||||
#[test]
|
||||
fn rpc_ethcore_dev_logs_levels() {
|
||||
let miner = miner_service();
|
||||
let client = blockchain_client();
|
||||
let ethcore = ethcore_client(&client, &miner).to_delegate();
|
||||
let ethcore = ethcore_client(&miner).to_delegate();
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(ethcore);
|
||||
|
||||
@ -207,8 +191,7 @@ fn rpc_ethcore_dev_logs_levels() {
|
||||
#[test]
|
||||
fn rpc_ethcore_set_transactions_limit() {
|
||||
let miner = miner_service();
|
||||
let client = blockchain_client();
|
||||
let ethcore = ethcore_client(&client, &miner).to_delegate();
|
||||
let ethcore = ethcore_client(&miner).to_delegate();
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(ethcore);
|
||||
|
||||
@ -222,8 +205,7 @@ fn rpc_ethcore_set_transactions_limit() {
|
||||
#[test]
|
||||
fn rpc_ethcore_transactions_limit() {
|
||||
let miner = miner_service();
|
||||
let client = blockchain_client();
|
||||
let ethcore = ethcore_client(&client, &miner).to_delegate();
|
||||
let ethcore = ethcore_client(&miner).to_delegate();
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(ethcore);
|
||||
|
||||
@ -236,8 +218,7 @@ fn rpc_ethcore_transactions_limit() {
|
||||
#[test]
|
||||
fn rpc_ethcore_net_chain() {
|
||||
let miner = miner_service();
|
||||
let client = blockchain_client();
|
||||
let ethcore = ethcore_client(&client, &miner).to_delegate();
|
||||
let ethcore = ethcore_client(&miner).to_delegate();
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(ethcore);
|
||||
|
||||
@ -250,8 +231,7 @@ fn rpc_ethcore_net_chain() {
|
||||
#[test]
|
||||
fn rpc_ethcore_net_max_peers() {
|
||||
let miner = miner_service();
|
||||
let client = blockchain_client();
|
||||
let ethcore = ethcore_client(&client, &miner).to_delegate();
|
||||
let ethcore = ethcore_client(&miner).to_delegate();
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(ethcore);
|
||||
|
||||
@ -264,8 +244,7 @@ fn rpc_ethcore_net_max_peers() {
|
||||
#[test]
|
||||
fn rpc_ethcore_net_port() {
|
||||
let miner = miner_service();
|
||||
let client = blockchain_client();
|
||||
let ethcore = ethcore_client(&client, &miner).to_delegate();
|
||||
let ethcore = ethcore_client(&miner).to_delegate();
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(ethcore);
|
||||
|
||||
@ -278,8 +257,7 @@ fn rpc_ethcore_net_port() {
|
||||
#[test]
|
||||
fn rpc_ethcore_rpc_settings() {
|
||||
let miner = miner_service();
|
||||
let client = blockchain_client();
|
||||
let ethcore = ethcore_client(&client, &miner).to_delegate();
|
||||
let ethcore = ethcore_client(&miner).to_delegate();
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(ethcore);
|
||||
|
||||
@ -292,8 +270,7 @@ fn rpc_ethcore_rpc_settings() {
|
||||
#[test]
|
||||
fn rpc_ethcore_node_name() {
|
||||
let miner = miner_service();
|
||||
let client = blockchain_client();
|
||||
let ethcore = ethcore_client(&client, &miner).to_delegate();
|
||||
let ethcore = ethcore_client(&miner).to_delegate();
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(ethcore);
|
||||
|
||||
|
@ -72,12 +72,6 @@ pub trait Ethcore: Sized + Send + Sync + 'static {
|
||||
/// Returns default extra data
|
||||
fn default_extra_data(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Executes the given call and returns the VM trace for it.
|
||||
fn vm_trace_call(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Executes the given call and returns the diff for it.
|
||||
fn state_diff_call(&self, params: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Should be used to convert object to io delegate.
|
||||
fn to_delegate(self) -> IoDelegate<Self> {
|
||||
let mut delegate = IoDelegate::new(Arc::new(self));
|
||||
@ -100,9 +94,6 @@ pub trait Ethcore: Sized + Send + Sync + 'static {
|
||||
delegate.add_method("ethcore_nodeName", Ethcore::node_name);
|
||||
delegate.add_method("ethcore_defaultExtraData", Ethcore::default_extra_data);
|
||||
|
||||
delegate.add_method("ethcore_vmTraceCall", Ethcore::vm_trace_call);
|
||||
delegate.add_method("ethcore_stateDiffCall", Ethcore::state_diff_call);
|
||||
|
||||
delegate
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,12 @@ pub trait Traces: Sized + Send + Sync + 'static {
|
||||
/// Returns all traces produced at given block.
|
||||
fn block_traces(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Executes the given call and returns the VM trace for it.
|
||||
fn vm_trace_call(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Executes the given call and returns the diff for it.
|
||||
fn state_diff_call(&self, params: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Should be used to convert object to io delegate.
|
||||
fn to_delegate(self) -> IoDelegate<Self> {
|
||||
let mut delegate = IoDelegate::new(Arc::new(self));
|
||||
@ -39,6 +45,10 @@ pub trait Traces: Sized + Send + Sync + 'static {
|
||||
delegate.add_method("trace_get", Traces::trace);
|
||||
delegate.add_method("trace_transaction", Traces::transaction_traces);
|
||||
delegate.add_method("trace_block", Traces::block_traces);
|
||||
|
||||
delegate.add_method("trace_vmTraceCall", Traces::vm_trace_call);
|
||||
delegate.add_method("trace_stateDiffCall", Traces::state_diff_call);
|
||||
|
||||
delegate
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user