serde is no longer util dependency (#1534)
* removed old json-tests * simplify folds in triehash.rs * removed unused json_aid * removed unused squeeze.rs * json branching tests for trie * removing todos from util * separated UsingQueue and Table * further cleanup, removing unused code * serde serialization of hash moved to rpc module * uint wrapper for rpc in progress * serialization of uint moved to rpc module * updated eth-secp256k1 * updated igd, serde is no longer dependency of util * loading trie consensus tests * renamed aliases in rpc imports
This commit is contained in:
@@ -38,7 +38,8 @@ use ethcore::log_entry::LogEntry;
|
||||
use ethcore::filter::Filter as EthcoreFilter;
|
||||
use self::ethash::SeedHashCompute;
|
||||
use v1::traits::Eth;
|
||||
use v1::types::{Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, SyncInfo, Transaction, CallRequest, OptionalValue, Index, Filter, Log, Receipt};
|
||||
use v1::types::{Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, SyncInfo, Transaction, CallRequest, Index, Filter, Log, Receipt, H64 as RpcH64, H256 as RpcH256, H160 as RpcH160, U256 as RpcU256};
|
||||
use v1::helpers::CallRequest as CRequest;
|
||||
use v1::impls::{default_gas_price, dispatch_transaction, error_codes};
|
||||
use serde;
|
||||
use ethcore::header::Header as BlockHeader;
|
||||
@@ -86,28 +87,28 @@ impl<C, S, M, EM> EthClient<C, S, M, EM> where
|
||||
let block_view = BlockView::new(&bytes);
|
||||
let view = block_view.header_view();
|
||||
let block = Block {
|
||||
hash: OptionalValue::Value(view.sha3()),
|
||||
parent_hash: view.parent_hash(),
|
||||
uncles_hash: view.uncles_hash(),
|
||||
author: view.author(),
|
||||
miner: view.author(),
|
||||
state_root: view.state_root(),
|
||||
transactions_root: view.transactions_root(),
|
||||
receipts_root: view.receipts_root(),
|
||||
number: OptionalValue::Value(U256::from(view.number())),
|
||||
gas_used: view.gas_used(),
|
||||
gas_limit: view.gas_limit(),
|
||||
logs_bloom: view.log_bloom(),
|
||||
timestamp: U256::from(view.timestamp()),
|
||||
difficulty: view.difficulty(),
|
||||
total_difficulty: total_difficulty,
|
||||
hash: Some(view.sha3().into()),
|
||||
parent_hash: view.parent_hash().into(),
|
||||
uncles_hash: view.uncles_hash().into(),
|
||||
author: view.author().into(),
|
||||
miner: view.author().into(),
|
||||
state_root: view.state_root().into(),
|
||||
transactions_root: view.transactions_root().into(),
|
||||
receipts_root: view.receipts_root().into(),
|
||||
number: Some(view.number().into()),
|
||||
gas_used: view.gas_used().into(),
|
||||
gas_limit: view.gas_limit().into(),
|
||||
logs_bloom: view.log_bloom().into(),
|
||||
timestamp: view.timestamp().into(),
|
||||
difficulty: view.difficulty().into(),
|
||||
total_difficulty: total_difficulty.into(),
|
||||
seal_fields: view.seal().into_iter().map(|f| decode(&f)).map(Bytes::new).collect(),
|
||||
uncles: block_view.uncle_hashes(),
|
||||
uncles: block_view.uncle_hashes().into_iter().map(Into::into).collect(),
|
||||
transactions: {
|
||||
if include_txs {
|
||||
BlockTransactions::Full(block_view.localized_transactions().into_iter().map(From::from).collect())
|
||||
BlockTransactions::Full(block_view.localized_transactions().into_iter().map(Into::into).collect())
|
||||
} else {
|
||||
BlockTransactions::Hashes(block_view.transaction_hashes())
|
||||
BlockTransactions::Hashes(block_view.transaction_hashes().into_iter().map(Into::into).collect())
|
||||
}
|
||||
},
|
||||
extra_data: Bytes::new(view.extra_data())
|
||||
@@ -127,7 +128,6 @@ impl<C, S, M, EM> EthClient<C, S, M, EM> where
|
||||
|
||||
fn uncle(&self, id: UncleID) -> Result<Value, Error> {
|
||||
let client = take_weak!(self.client);
|
||||
|
||||
let uncle: BlockHeader = match client.uncle(id) {
|
||||
Some(rlp) => decode(&rlp),
|
||||
None => { return Ok(Value::Null); }
|
||||
@@ -138,22 +138,22 @@ impl<C, S, M, EM> EthClient<C, S, M, EM> where
|
||||
};
|
||||
|
||||
let block = Block {
|
||||
hash: OptionalValue::Value(uncle.hash()),
|
||||
parent_hash: uncle.parent_hash,
|
||||
uncles_hash: uncle.uncles_hash,
|
||||
author: uncle.author,
|
||||
miner: uncle.author,
|
||||
state_root: uncle.state_root,
|
||||
transactions_root: uncle.transactions_root,
|
||||
number: OptionalValue::Value(U256::from(uncle.number)),
|
||||
gas_used: uncle.gas_used,
|
||||
gas_limit: uncle.gas_limit,
|
||||
logs_bloom: uncle.log_bloom,
|
||||
timestamp: U256::from(uncle.timestamp),
|
||||
difficulty: uncle.difficulty,
|
||||
total_difficulty: uncle.difficulty + parent_difficulty,
|
||||
receipts_root: uncle.receipts_root,
|
||||
extra_data: Bytes::new(uncle.extra_data),
|
||||
hash: Some(uncle.hash().into()),
|
||||
parent_hash: uncle.parent_hash.into(),
|
||||
uncles_hash: uncle.uncles_hash.into(),
|
||||
author: uncle.author.into(),
|
||||
miner: uncle.author.into(),
|
||||
state_root: uncle.state_root.into(),
|
||||
transactions_root: uncle.transactions_root.into(),
|
||||
number: Some(uncle.number.into()),
|
||||
gas_used: uncle.gas_used.into(),
|
||||
gas_limit: uncle.gas_limit.into(),
|
||||
logs_bloom: uncle.log_bloom.into(),
|
||||
timestamp: uncle.timestamp.into(),
|
||||
difficulty: uncle.difficulty.into(),
|
||||
total_difficulty: (uncle.difficulty + parent_difficulty).into(),
|
||||
receipts_root: uncle.receipts_root.into(),
|
||||
extra_data: uncle.extra_data.into(),
|
||||
seal_fields: uncle.seal.into_iter().map(|f| decode(&f)).map(Bytes::new).collect(),
|
||||
uncles: vec![],
|
||||
transactions: BlockTransactions::Hashes(vec![]),
|
||||
@@ -161,7 +161,7 @@ impl<C, S, M, EM> EthClient<C, S, M, EM> where
|
||||
to_value(&block)
|
||||
}
|
||||
|
||||
fn sign_call(&self, request: CallRequest) -> Result<SignedTransaction, Error> {
|
||||
fn sign_call(&self, request: CRequest) -> Result<SignedTransaction, Error> {
|
||||
let (client, miner) = (take_weak!(self.client), take_weak!(self.miner));
|
||||
let from = request.from.unwrap_or(Address::zero());
|
||||
Ok(EthTransaction {
|
||||
@@ -186,7 +186,7 @@ pub fn pending_logs<M>(miner: &M, filter: &EthcoreFilter) -> Vec<Log> where M: M
|
||||
.filter(|pair| filter.matches(&pair.1))
|
||||
.map(|pair| {
|
||||
let mut log = Log::from(pair.1);
|
||||
log.transaction_hash = Some(pair.0);
|
||||
log.transaction_hash = Some(pair.0.into());
|
||||
log
|
||||
})
|
||||
.collect();
|
||||
@@ -277,15 +277,17 @@ impl<C, S, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
SyncState::Idle => SyncStatus::None,
|
||||
SyncState::Waiting | SyncState::Blocks | SyncState::NewBlocks | SyncState::ChainHead => {
|
||||
let current_block = U256::from(take_weak!(self.client).chain_info().best_block_number);
|
||||
let highest_block = U256::from(status.highest_block_number.unwrap_or(status.start_block_number));
|
||||
|
||||
let info = SyncInfo {
|
||||
starting_block: U256::from(status.start_block_number),
|
||||
current_block: current_block,
|
||||
highest_block: U256::from(status.highest_block_number.unwrap_or(status.start_block_number))
|
||||
};
|
||||
match info.highest_block > info.current_block + U256::from(6) {
|
||||
true => SyncStatus::Info(info),
|
||||
false => SyncStatus::None,
|
||||
if highest_block > current_block + U256::from(6) {
|
||||
let info = SyncInfo {
|
||||
starting_block: status.start_block_number.into(),
|
||||
current_block: current_block.into(),
|
||||
highest_block: highest_block.into(),
|
||||
};
|
||||
SyncStatus::Info(info)
|
||||
} else {
|
||||
SyncStatus::None
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -298,7 +300,7 @@ impl<C, S, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
fn author(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
match params {
|
||||
Params::None => to_value(&take_weak!(self.miner).author()),
|
||||
Params::None => to_value(&RpcH160::from(take_weak!(self.miner).author())),
|
||||
_ => Err(Error::invalid_params()),
|
||||
}
|
||||
}
|
||||
@@ -314,7 +316,7 @@ impl<C, S, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
fn hashrate(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
match params {
|
||||
Params::None => to_value(&self.external_miner.hashrate()),
|
||||
Params::None => to_value(&RpcU256::from(self.external_miner.hashrate())),
|
||||
_ => Err(Error::invalid_params())
|
||||
}
|
||||
}
|
||||
@@ -324,7 +326,7 @@ impl<C, S, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
match params {
|
||||
Params::None => {
|
||||
let (client, miner) = (take_weak!(self.client), take_weak!(self.miner));
|
||||
to_value(&default_gas_price(&*client, &*miner))
|
||||
to_value(&RpcU256::from(default_gas_price(&*client, &*miner)))
|
||||
}
|
||||
_ => Err(Error::invalid_params())
|
||||
}
|
||||
@@ -333,13 +335,13 @@ impl<C, S, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
fn accounts(&self, _: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
let store = take_weak!(self.accounts);
|
||||
to_value(&store.accounts())
|
||||
to_value(&store.accounts().into_iter().map(Into::into).collect::<Vec<RpcH160>>())
|
||||
}
|
||||
|
||||
fn block_number(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
match params {
|
||||
Params::None => to_value(&U256::from(take_weak!(self.client).chain_info().best_block_number)),
|
||||
Params::None => to_value(&RpcU256::from(take_weak!(self.client).chain_info().best_block_number)),
|
||||
_ => Err(Error::invalid_params())
|
||||
}
|
||||
}
|
||||
@@ -347,39 +349,50 @@ impl<C, S, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
fn balance(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params_default_second(params)
|
||||
.and_then(|(address, block_number,)| match block_number {
|
||||
BlockNumber::Pending => to_value(&take_weak!(self.miner).balance(take_weak!(self.client).deref(), &address)),
|
||||
id => to_value(&try!(take_weak!(self.client).balance(&address, id.into()).ok_or_else(make_unsupported_err))),
|
||||
.and_then(|(address, block_number,)| {
|
||||
let address: Address = RpcH160::into(address);
|
||||
match block_number {
|
||||
BlockNumber::Pending => to_value(&RpcU256::from(take_weak!(self.miner).balance(take_weak!(self.client).deref(), &address))),
|
||||
id => to_value(&RpcU256::from(try!(take_weak!(self.client).balance(&address, id.into()).ok_or_else(make_unsupported_err)))),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn storage_at(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params_default_third::<Address, U256>(params)
|
||||
.and_then(|(address, position, block_number,)| match block_number {
|
||||
BlockNumber::Pending => to_value(&U256::from(take_weak!(self.miner).storage_at(&*take_weak!(self.client), &address, &H256::from(position)))),
|
||||
id => match take_weak!(self.client).storage_at(&address, &H256::from(position), id.into()) {
|
||||
Some(s) => to_value(&U256::from(s)),
|
||||
None => Err(make_unsupported_err()), // None is only returned on unsupported requests.
|
||||
from_params_default_third::<RpcH160, RpcU256>(params)
|
||||
.and_then(|(address, position, block_number,)| {
|
||||
let address: Address = RpcH160::into(address);
|
||||
let position: U256 = RpcU256::into(position);
|
||||
match block_number {
|
||||
BlockNumber::Pending => to_value(&RpcU256::from(take_weak!(self.miner).storage_at(&*take_weak!(self.client), &address, &H256::from(position)))),
|
||||
id => match take_weak!(self.client).storage_at(&address, &H256::from(position), id.into()) {
|
||||
Some(s) => to_value(&RpcU256::from(s)),
|
||||
None => Err(make_unsupported_err()), // None is only returned on unsupported requests.
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
fn transaction_count(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params_default_second(params)
|
||||
.and_then(|(address, block_number,)| match block_number {
|
||||
BlockNumber::Pending => to_value(&take_weak!(self.miner).nonce(take_weak!(self.client).deref(), &address)),
|
||||
id => to_value(&take_weak!(self.client).nonce(&address, id.into())),
|
||||
.and_then(|(address, block_number,)| {
|
||||
let address: Address = RpcH160::into(address);
|
||||
match block_number {
|
||||
BlockNumber::Pending => to_value(&RpcU256::from(take_weak!(self.miner).nonce(take_weak!(self.client).deref(), &address))),
|
||||
id => to_value(&take_weak!(self.client).nonce(&address, id.into()).map(RpcU256::from)),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn block_transaction_count_by_hash(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params::<(H256,)>(params)
|
||||
from_params::<(RpcH256,)>(params)
|
||||
.and_then(|(hash,)| // match
|
||||
take_weak!(self.client).block(BlockID::Hash(hash))
|
||||
.map_or(Ok(Value::Null), |bytes| to_value(&U256::from(BlockView::new(&bytes).transactions_count()))))
|
||||
take_weak!(self.client).block(BlockID::Hash(hash.into()))
|
||||
.map_or(Ok(Value::Null), |bytes| to_value(&RpcU256::from(BlockView::new(&bytes).transactions_count()))))
|
||||
}
|
||||
|
||||
fn block_transaction_count_by_number(&self, params: Params) -> Result<Value, Error> {
|
||||
@@ -387,45 +400,48 @@ impl<C, S, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
from_params::<(BlockNumber,)>(params)
|
||||
.and_then(|(block_number,)| match block_number {
|
||||
BlockNumber::Pending => to_value(
|
||||
&U256::from(take_weak!(self.miner).status().transactions_in_pending_block)
|
||||
&RpcU256::from(take_weak!(self.miner).status().transactions_in_pending_block)
|
||||
),
|
||||
_ => take_weak!(self.client).block(block_number.into())
|
||||
.map_or(Ok(Value::Null), |bytes| to_value(&U256::from(BlockView::new(&bytes).transactions_count())))
|
||||
.map_or(Ok(Value::Null), |bytes| to_value(&RpcU256::from(BlockView::new(&bytes).transactions_count())))
|
||||
})
|
||||
}
|
||||
|
||||
fn block_uncles_count_by_hash(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params::<(H256,)>(params)
|
||||
from_params::<(RpcH256,)>(params)
|
||||
.and_then(|(hash,)|
|
||||
take_weak!(self.client).block(BlockID::Hash(hash))
|
||||
.map_or(Ok(Value::Null), |bytes| to_value(&U256::from(BlockView::new(&bytes).uncles_count()))))
|
||||
take_weak!(self.client).block(BlockID::Hash(hash.into()))
|
||||
.map_or(Ok(Value::Null), |bytes| to_value(&RpcU256::from(BlockView::new(&bytes).uncles_count()))))
|
||||
}
|
||||
|
||||
fn block_uncles_count_by_number(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params::<(BlockNumber,)>(params)
|
||||
.and_then(|(block_number,)| match block_number {
|
||||
BlockNumber::Pending => to_value(&U256::from(0)),
|
||||
BlockNumber::Pending => to_value(&RpcU256::from(0)),
|
||||
_ => take_weak!(self.client).block(block_number.into())
|
||||
.map_or(Ok(Value::Null), |bytes| to_value(&U256::from(BlockView::new(&bytes).uncles_count())))
|
||||
.map_or(Ok(Value::Null), |bytes| to_value(&RpcU256::from(BlockView::new(&bytes).uncles_count())))
|
||||
})
|
||||
}
|
||||
|
||||
fn code_at(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params_default_second(params)
|
||||
.and_then(|(address, block_number,)| match block_number {
|
||||
BlockNumber::Pending => to_value(&take_weak!(self.miner).code(take_weak!(self.client).deref(), &address).map_or_else(Bytes::default, Bytes::new)),
|
||||
BlockNumber::Latest => to_value(&take_weak!(self.client).code(&address).map_or_else(Bytes::default, Bytes::new)),
|
||||
_ => Err(Error::invalid_params()),
|
||||
.and_then(|(address, block_number,)| {
|
||||
let address: Address = RpcH160::into(address);
|
||||
match block_number {
|
||||
BlockNumber::Pending => to_value(&take_weak!(self.miner).code(take_weak!(self.client).deref(), &address).map_or_else(Bytes::default, Bytes::new)),
|
||||
BlockNumber::Latest => to_value(&take_weak!(self.client).code(&address).map_or_else(Bytes::default, Bytes::new)),
|
||||
_ => Err(Error::invalid_params()),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn block_by_hash(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params::<(H256, bool)>(params)
|
||||
.and_then(|(hash, include_txs)| self.block(BlockID::Hash(hash), include_txs))
|
||||
from_params::<(RpcH256, bool)>(params)
|
||||
.and_then(|(hash, include_txs)| self.block(BlockID::Hash(hash.into()), include_txs))
|
||||
}
|
||||
|
||||
fn block_by_number(&self, params: Params) -> Result<Value, Error> {
|
||||
@@ -436,9 +452,10 @@ impl<C, S, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
|
||||
fn transaction_by_hash(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params::<(H256,)>(params)
|
||||
from_params::<(RpcH256,)>(params)
|
||||
.and_then(|(hash,)| {
|
||||
let miner = take_weak!(self.miner);
|
||||
let hash: H256 = hash.into();
|
||||
match miner.transaction(&hash) {
|
||||
Some(pending_tx) => to_value(&Transaction::from(pending_tx)),
|
||||
None => self.transaction(TransactionID::Hash(hash))
|
||||
@@ -448,8 +465,8 @@ impl<C, S, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
|
||||
fn transaction_by_block_hash_and_index(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params::<(H256, Index)>(params)
|
||||
.and_then(|(hash, index)| self.transaction(TransactionID::Location(BlockID::Hash(hash), index.value())))
|
||||
from_params::<(RpcH256, Index)>(params)
|
||||
.and_then(|(hash, index)| self.transaction(TransactionID::Location(BlockID::Hash(hash.into()), index.value())))
|
||||
}
|
||||
|
||||
fn transaction_by_block_number_and_index(&self, params: Params) -> Result<Value, Error> {
|
||||
@@ -460,9 +477,10 @@ impl<C, S, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
|
||||
fn transaction_receipt(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params::<(H256,)>(params)
|
||||
from_params::<(RpcH256,)>(params)
|
||||
.and_then(|(hash,)| {
|
||||
let miner = take_weak!(self.miner);
|
||||
let hash: H256 = hash.into();
|
||||
match miner.pending_receipts().get(&hash) {
|
||||
Some(receipt) if self.allow_pending_receipt_query => to_value(&Receipt::from(receipt.clone())),
|
||||
_ => {
|
||||
@@ -476,8 +494,8 @@ impl<C, S, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
|
||||
fn uncle_by_block_hash_and_index(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params::<(H256, Index)>(params)
|
||||
.and_then(|(hash, index)| self.uncle(UncleID { block: BlockID::Hash(hash), position: index.value() }))
|
||||
from_params::<(RpcH256, Index)>(params)
|
||||
.and_then(|(hash, index)| self.uncle(UncleID { block: BlockID::Hash(hash.into()), position: index.value() }))
|
||||
}
|
||||
|
||||
fn uncle_by_block_number_and_index(&self, params: Params) -> Result<Value, Error> {
|
||||
@@ -543,8 +561,9 @@ impl<C, S, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
miner.map_sealing_work(client.deref(), |b| {
|
||||
let pow_hash = b.hash();
|
||||
let target = Ethash::difficulty_to_boundary(b.block().header().difficulty());
|
||||
let seed_hash = &self.seed_compute.lock().unwrap().get_seedhash(b.block().header().number());
|
||||
to_value(&(pow_hash, H256::from_slice(&seed_hash[..]), target, &U256::from(b.block().header().number())))
|
||||
let seed_hash = self.seed_compute.lock().unwrap().get_seedhash(b.block().header().number());
|
||||
let block_number = RpcU256::from(b.block().header().number());
|
||||
to_value(&(RpcH256::from(pow_hash), RpcH256::from(seed_hash), RpcH256::from(target), block_number))
|
||||
}).unwrap_or(Err(Error::internal_error())) // no work found.
|
||||
},
|
||||
_ => Err(Error::invalid_params())
|
||||
@@ -553,7 +572,10 @@ impl<C, S, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
|
||||
fn submit_work(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params::<(H64, H256, H256)>(params).and_then(|(nonce, pow_hash, mix_hash)| {
|
||||
from_params::<(RpcH64, RpcH256, RpcH256)>(params).and_then(|(nonce, pow_hash, mix_hash)| {
|
||||
let nonce: H64 = nonce.into();
|
||||
let pow_hash: H256 = pow_hash.into();
|
||||
let mix_hash: H256 = mix_hash.into();
|
||||
trace!(target: "miner", "submit_work: Decoded: nonce={}, pow_hash={}, mix_hash={}", nonce, pow_hash, mix_hash);
|
||||
let miner = take_weak!(self.miner);
|
||||
let client = take_weak!(self.client);
|
||||
@@ -565,8 +587,8 @@ impl<C, S, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
|
||||
fn submit_hashrate(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params::<(U256, H256)>(params).and_then(|(rate, id)| {
|
||||
self.external_miner.submit_hashrate(rate, id);
|
||||
from_params::<(RpcU256, RpcH256)>(params).and_then(|(rate, id)| {
|
||||
self.external_miner.submit_hashrate(rate.into(), id.into());
|
||||
to_value(&true)
|
||||
})
|
||||
}
|
||||
@@ -578,7 +600,7 @@ impl<C, S, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
let raw_transaction = raw_transaction.to_vec();
|
||||
match UntrustedRlp::new(&raw_transaction).as_val() {
|
||||
Ok(signed_transaction) => dispatch_transaction(&*take_weak!(self.client), &*take_weak!(self.miner), signed_transaction),
|
||||
Err(_) => to_value(&H256::zero()),
|
||||
Err(_) => to_value(&RpcH256::from(H256::from(0))),
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -588,6 +610,7 @@ impl<C, S, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
trace!(target: "jsonrpc", "call: {:?}", params);
|
||||
from_params_default_second(params)
|
||||
.and_then(|(request, block_number,)| {
|
||||
let request = CallRequest::into(request);
|
||||
let signed = try!(self.sign_call(request));
|
||||
let r = match block_number {
|
||||
BlockNumber::Pending => take_weak!(self.miner).call(take_weak!(self.client).deref(), &signed, Default::default()),
|
||||
@@ -602,13 +625,14 @@ impl<C, S, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
try!(self.active());
|
||||
from_params_default_second(params)
|
||||
.and_then(|(request, block_number,)| {
|
||||
let request = CallRequest::into(request);
|
||||
let signed = try!(self.sign_call(request));
|
||||
let r = match block_number {
|
||||
BlockNumber::Pending => take_weak!(self.miner).call(take_weak!(self.client).deref(), &signed, Default::default()),
|
||||
BlockNumber::Latest => take_weak!(self.client).call(&signed, Default::default()),
|
||||
_ => return Err(Error::invalid_params()),
|
||||
};
|
||||
to_value(&r.map(|res| res.gas_used + res.refunded).unwrap_or(From::from(0)))
|
||||
to_value(&RpcU256::from(r.map(|res| res.gas_used + res.refunded).unwrap_or(From::from(0))))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ use ethcore::miner::MinerService;
|
||||
use ethcore::filter::Filter as EthcoreFilter;
|
||||
use ethcore::client::{BlockChainClient, BlockID};
|
||||
use v1::traits::EthFilter;
|
||||
use v1::types::{BlockNumber, Index, Filter, Log};
|
||||
use v1::types::{BlockNumber, Index, Filter, Log, H256 as RpcH256, U256 as RpcU256};
|
||||
use v1::helpers::{PollFilter, PollManager};
|
||||
use v1::impls::eth::pending_logs;
|
||||
|
||||
@@ -71,7 +71,7 @@ impl<C, M> EthFilter for EthFilterClient<C, M> where
|
||||
let mut polls = self.polls.lock().unwrap();
|
||||
let block_number = take_weak!(self.client).chain_info().best_block_number;
|
||||
let id = polls.create_poll(PollFilter::Logs(block_number, Default::default(), filter));
|
||||
to_value(&U256::from(id))
|
||||
to_value(&RpcU256::from(id))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ impl<C, M> EthFilter for EthFilterClient<C, M> where
|
||||
Params::None => {
|
||||
let mut polls = self.polls.lock().unwrap();
|
||||
let id = polls.create_poll(PollFilter::Block(take_weak!(self.client).chain_info().best_block_number));
|
||||
to_value(&U256::from(id))
|
||||
to_value(&RpcU256::from(id))
|
||||
},
|
||||
_ => Err(Error::invalid_params())
|
||||
}
|
||||
@@ -95,7 +95,7 @@ impl<C, M> EthFilter for EthFilterClient<C, M> where
|
||||
let pending_transactions = take_weak!(self.miner).pending_transactions_hashes();
|
||||
let id = polls.create_poll(PollFilter::PendingTransaction(pending_transactions));
|
||||
|
||||
to_value(&U256::from(id))
|
||||
to_value(&RpcU256::from(id))
|
||||
},
|
||||
_ => Err(Error::invalid_params())
|
||||
}
|
||||
@@ -116,7 +116,8 @@ impl<C, M> EthFilter for EthFilterClient<C, M> where
|
||||
let hashes = (*block_number..current_number).into_iter()
|
||||
.map(BlockID::Number)
|
||||
.filter_map(|id| client.block_hash(id))
|
||||
.collect::<Vec<H256>>();
|
||||
.map(Into::into)
|
||||
.collect::<Vec<RpcH256>>();
|
||||
|
||||
*block_number = current_number;
|
||||
|
||||
@@ -135,7 +136,8 @@ impl<C, M> EthFilter for EthFilterClient<C, M> where
|
||||
.iter()
|
||||
.filter(|hash| !previous_hashes_set.contains(hash))
|
||||
.cloned()
|
||||
.collect::<Vec<H256>>()
|
||||
.map(Into::into)
|
||||
.collect::<Vec<RpcH256>>()
|
||||
};
|
||||
|
||||
// save all hashes of pending transactions
|
||||
|
||||
@@ -20,17 +20,17 @@ use std::sync::{Arc, Weak};
|
||||
use jsonrpc_core::*;
|
||||
use ethcore::miner::MinerService;
|
||||
use ethcore::client::MiningBlockChainClient;
|
||||
use util::numbers::*;
|
||||
use util::{U256, Address, H256};
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use v1::helpers::{SigningQueue, ConfirmationsQueue};
|
||||
use v1::helpers::{SigningQueue, ConfirmationsQueue, TransactionRequest as TRequest};
|
||||
use v1::traits::EthSigning;
|
||||
use v1::types::{TransactionRequest, Bytes};
|
||||
use v1::types::{TransactionRequest, H160 as RpcH160, H256 as RpcH256, H520 as RpcH520};
|
||||
use v1::impls::{default_gas_price, sign_and_dispatch};
|
||||
|
||||
fn fill_optional_fields<C, M>(request: &mut TransactionRequest, client: &C, miner: &M)
|
||||
fn fill_optional_fields<C, M>(request: &mut TRequest, client: &C, miner: &M)
|
||||
where C: MiningBlockChainClient, M: MinerService {
|
||||
if request.value.is_none() {
|
||||
request.value = Some(U256::zero());
|
||||
request.value = Some(U256::from(0));
|
||||
}
|
||||
if request.gas.is_none() {
|
||||
request.gas = Some(miner.sensible_gas_limit());
|
||||
@@ -39,7 +39,7 @@ fn fill_optional_fields<C, M>(request: &mut TransactionRequest, client: &C, mine
|
||||
request.gas_price = Some(default_gas_price(client, miner));
|
||||
}
|
||||
if request.data.is_none() {
|
||||
request.data = Some(Bytes::new(Vec::new()));
|
||||
request.data = Some(Vec::new());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,8 @@ impl<C, M> EthSigning for EthSigningQueueClient<C, M>
|
||||
fn send_transaction(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params::<(TransactionRequest, )>(params)
|
||||
.and_then(|(mut request, )| {
|
||||
.and_then(|(request, )| {
|
||||
let mut request: TRequest = request.into();
|
||||
let accounts = take_weak!(self.accounts);
|
||||
let (client, miner) = (take_weak!(self.client), take_weak!(self.miner));
|
||||
|
||||
@@ -91,7 +92,7 @@ impl<C, M> EthSigning for EthSigningQueueClient<C, M>
|
||||
let sender = request.from;
|
||||
return match sign_and_dispatch(&*client, &*miner, request, &*accounts, sender) {
|
||||
Ok(hash) => to_value(&hash),
|
||||
_ => to_value(&H256::zero()),
|
||||
_ => to_value(&RpcH256::default()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +100,7 @@ impl<C, M> EthSigning for EthSigningQueueClient<C, M>
|
||||
fill_optional_fields(&mut request, &*client, &*miner);
|
||||
let id = queue.add_request(request);
|
||||
let result = id.wait_with_timeout();
|
||||
result.unwrap_or_else(|| to_value(&H256::new()))
|
||||
result.unwrap_or_else(|| to_value(&RpcH256::default()))
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -140,8 +141,10 @@ impl<C, M> EthSigning for EthSigningUnsafeClient<C, M> where
|
||||
|
||||
fn sign(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params::<(Address, H256)>(params).and_then(|(addr, msg)| {
|
||||
to_value(&take_weak!(self.accounts).sign(addr, msg).unwrap_or(H520::zero()))
|
||||
from_params::<(RpcH160, RpcH256)>(params).and_then(|(address, msg)| {
|
||||
let address: Address = address.into();
|
||||
let msg: H256 = msg.into();
|
||||
to_value(&take_weak!(self.accounts).sign(address, msg).ok().map_or_else(RpcH520::default, Into::into))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -149,10 +152,11 @@ impl<C, M> EthSigning for EthSigningUnsafeClient<C, M> where
|
||||
try!(self.active());
|
||||
from_params::<(TransactionRequest, )>(params)
|
||||
.and_then(|(request, )| {
|
||||
let request: TRequest = request.into();
|
||||
let sender = request.from;
|
||||
match sign_and_dispatch(&*take_weak!(self.client), &*take_weak!(self.miner), request, &*take_weak!(self.accounts), sender) {
|
||||
Ok(hash) => to_value(&hash),
|
||||
_ => to_value(&H256::zero()),
|
||||
_ => to_value(&RpcH256::default()),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ use ethcore::client::{MiningBlockChainClient};
|
||||
use jsonrpc_core::*;
|
||||
use ethcore::miner::MinerService;
|
||||
use v1::traits::Ethcore;
|
||||
use v1::types::{Bytes};
|
||||
use v1::types::{Bytes, U256};
|
||||
use v1::helpers::{SigningQueue, ConfirmationsQueue};
|
||||
use v1::impls::error_codes;
|
||||
|
||||
@@ -69,7 +69,7 @@ impl<C, M> Ethcore for EthcoreClient<C, M> where M: MinerService + 'static, C: M
|
||||
|
||||
fn min_gas_price(&self, _: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
to_value(&take_weak!(self.miner).minimal_gas_price())
|
||||
to_value(&U256::from(take_weak!(self.miner).minimal_gas_price()))
|
||||
}
|
||||
|
||||
fn extra_data(&self, _: Params) -> Result<Value, Error> {
|
||||
@@ -79,12 +79,12 @@ impl<C, M> Ethcore for EthcoreClient<C, M> where M: MinerService + 'static, C: M
|
||||
|
||||
fn gas_floor_target(&self, _: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
to_value(&take_weak!(self.miner).gas_floor_target())
|
||||
to_value(&U256::from(take_weak!(self.miner).gas_floor_target()))
|
||||
}
|
||||
|
||||
fn gas_ceil_target(&self, _: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
to_value(&take_weak!(self.miner).gas_ceil_target())
|
||||
to_value(&U256::from(take_weak!(self.miner).gas_ceil_target()))
|
||||
}
|
||||
|
||||
fn dev_logs(&self, _params: Params) -> Result<Value, Error> {
|
||||
@@ -140,8 +140,8 @@ impl<C, M> Ethcore for EthcoreClient<C, M> where M: MinerService + 'static, C: M
|
||||
match params {
|
||||
Params::None => match take_weak!(self.client).gas_price_statistics(100, 8) {
|
||||
Ok(stats) => to_value(&stats
|
||||
.iter()
|
||||
.map(|x| to_value(&x).expect("x must be U256; qed"))
|
||||
.into_iter()
|
||||
.map(|x| to_value(&U256::from(x)).expect("x must be U256; qed"))
|
||||
.collect::<Vec<_>>()),
|
||||
_ => Err(Error::internal_error()),
|
||||
},
|
||||
|
||||
@@ -15,15 +15,14 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/// Ethcore-specific rpc interface for operations altering the settings.
|
||||
use util::{U256, Address};
|
||||
use util::network::{NetworkService, NonReservedPeerMode};
|
||||
use std::sync::{Arc, Weak};
|
||||
use jsonrpc_core::*;
|
||||
use ethcore::miner::MinerService;
|
||||
use ethcore::client::MiningBlockChainClient;
|
||||
use ethcore::service::SyncMessage;
|
||||
use util::network::{NetworkService, NonReservedPeerMode};
|
||||
use v1::traits::EthcoreSet;
|
||||
use v1::types::Bytes;
|
||||
use v1::types::{Bytes, H160, U256};
|
||||
|
||||
/// Ethcore-specific rpc interface for operations altering the settings.
|
||||
pub struct EthcoreSetClient<C, M> where
|
||||
@@ -61,7 +60,7 @@ impl<C, M> EthcoreSet for EthcoreSetClient<C, M> where
|
||||
fn set_min_gas_price(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params::<(U256,)>(params).and_then(|(gas_price,)| {
|
||||
take_weak!(self.miner).set_minimal_gas_price(gas_price);
|
||||
take_weak!(self.miner).set_minimal_gas_price(gas_price.into());
|
||||
to_value(&true)
|
||||
})
|
||||
}
|
||||
@@ -69,7 +68,7 @@ impl<C, M> EthcoreSet for EthcoreSetClient<C, M> where
|
||||
fn set_gas_floor_target(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params::<(U256,)>(params).and_then(|(target,)| {
|
||||
take_weak!(self.miner).set_gas_floor_target(target);
|
||||
take_weak!(self.miner).set_gas_floor_target(target.into());
|
||||
to_value(&true)
|
||||
})
|
||||
}
|
||||
@@ -77,7 +76,7 @@ impl<C, M> EthcoreSet for EthcoreSetClient<C, M> where
|
||||
fn set_gas_ceil_target(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params::<(U256,)>(params).and_then(|(target,)| {
|
||||
take_weak!(self.miner).set_gas_ceil_target(target);
|
||||
take_weak!(self.miner).set_gas_ceil_target(target.into());
|
||||
to_value(&true)
|
||||
})
|
||||
}
|
||||
@@ -92,8 +91,8 @@ impl<C, M> EthcoreSet for EthcoreSetClient<C, M> where
|
||||
|
||||
fn set_author(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params::<(Address,)>(params).and_then(|(author,)| {
|
||||
take_weak!(self.miner).set_author(author);
|
||||
from_params::<(H160,)>(params).and_then(|(author,)| {
|
||||
take_weak!(self.miner).set_author(author.into());
|
||||
to_value(&true)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -53,7 +53,8 @@ pub use self::ethcore_set::EthcoreSetClient;
|
||||
pub use self::traces::TracesClient;
|
||||
pub use self::rpc::RpcClient;
|
||||
|
||||
use v1::types::TransactionRequest;
|
||||
use v1::helpers::TransactionRequest;
|
||||
use v1::types::H256 as NH256;
|
||||
use ethcore::error::Error as EthcoreError;
|
||||
use ethcore::miner::{AccountDetails, MinerService};
|
||||
use ethcore::client::MiningBlockChainClient;
|
||||
@@ -77,7 +78,7 @@ mod error_codes {
|
||||
|
||||
fn dispatch_transaction<C, M>(client: &C, miner: &M, signed_transaction: SignedTransaction) -> Result<Value, Error>
|
||||
where C: MiningBlockChainClient, M: MinerService {
|
||||
let hash = signed_transaction.hash();
|
||||
let hash = NH256::from(signed_transaction.hash());
|
||||
|
||||
let import = miner.import_own_transaction(client, signed_transaction, |a: &Address| {
|
||||
AccountDetails {
|
||||
|
||||
@@ -18,10 +18,11 @@
|
||||
use std::sync::{Arc, Weak};
|
||||
use jsonrpc_core::*;
|
||||
use v1::traits::Personal;
|
||||
use v1::types::TransactionRequest;
|
||||
use v1::types::{H160 as RpcH160, H256 as RpcH256, TransactionRequest};
|
||||
use v1::impls::unlock_sign_and_dispatch;
|
||||
use v1::helpers::{TransactionRequest as TRequest};
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use util::numbers::*;
|
||||
use util::Address;
|
||||
use ethcore::client::MiningBlockChainClient;
|
||||
use ethcore::miner::MinerService;
|
||||
|
||||
@@ -63,7 +64,7 @@ impl<C: 'static, M: 'static> Personal for PersonalClient<C, M> where C: MiningBl
|
||||
fn accounts(&self, _: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
let store = take_weak!(self.accounts);
|
||||
to_value(&store.accounts())
|
||||
to_value(&store.accounts().into_iter().map(Into::into).collect::<Vec<RpcH160>>())
|
||||
}
|
||||
|
||||
fn new_account(&self, params: Params) -> Result<Value, Error> {
|
||||
@@ -72,7 +73,7 @@ impl<C: 'static, M: 'static> Personal for PersonalClient<C, M> where C: MiningBl
|
||||
|(pass, )| {
|
||||
let store = take_weak!(self.accounts);
|
||||
match store.new_account(&pass) {
|
||||
Ok(address) => to_value(&address),
|
||||
Ok(address) => to_value(&RpcH160::from(address)),
|
||||
Err(_) => Err(Error::internal_error())
|
||||
}
|
||||
}
|
||||
@@ -81,8 +82,9 @@ impl<C: 'static, M: 'static> Personal for PersonalClient<C, M> where C: MiningBl
|
||||
|
||||
fn unlock_account(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params::<(Address, String, u64)>(params).and_then(
|
||||
from_params::<(RpcH160, String, u64)>(params).and_then(
|
||||
|(account, account_pass, _)|{
|
||||
let account: Address = account.into();
|
||||
let store = take_weak!(self.accounts);
|
||||
match store.unlock_account_temporarily(account, account_pass) {
|
||||
Ok(_) => Ok(Value::Bool(true)),
|
||||
@@ -95,12 +97,13 @@ impl<C: 'static, M: 'static> Personal for PersonalClient<C, M> where C: MiningBl
|
||||
try!(self.active());
|
||||
from_params::<(TransactionRequest, String)>(params)
|
||||
.and_then(|(request, password)| {
|
||||
let request: TRequest = request.into();
|
||||
let sender = request.from;
|
||||
let accounts = take_weak!(self.accounts);
|
||||
|
||||
match unlock_sign_and_dispatch(&*take_weak!(self.client), &*take_weak!(self.miner), request, &*accounts, sender, password) {
|
||||
Ok(hash) => to_value(&hash),
|
||||
_ => to_value(&H256::zero()),
|
||||
Ok(hash) => Ok(hash),
|
||||
_ => to_value(&RpcH256::default()),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -18,14 +18,13 @@
|
||||
|
||||
use std::sync::{Arc, Weak};
|
||||
use jsonrpc_core::*;
|
||||
use v1::traits::PersonalSigner;
|
||||
use v1::types::TransactionModification;
|
||||
use v1::impls::unlock_sign_and_dispatch;
|
||||
use v1::helpers::{SigningQueue, ConfirmationsQueue};
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use util::numbers::*;
|
||||
use ethcore::client::MiningBlockChainClient;
|
||||
use ethcore::miner::MinerService;
|
||||
use v1::traits::PersonalSigner;
|
||||
use v1::types::{TransactionModification, TransactionConfirmation, U256};
|
||||
use v1::impls::unlock_sign_and_dispatch;
|
||||
use v1::helpers::{SigningQueue, ConfirmationsQueue};
|
||||
|
||||
/// Transactions confirmation (personal) rpc implementation.
|
||||
pub struct SignerClient<C, M> where C: MiningBlockChainClient, M: MinerService {
|
||||
@@ -59,13 +58,14 @@ impl<C: 'static, M: 'static> PersonalSigner for SignerClient<C, M> where C: Mini
|
||||
fn transactions_to_confirm(&self, _params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
let queue = take_weak!(self.queue);
|
||||
to_value(&queue.requests())
|
||||
to_value(&queue.requests().into_iter().map(From::from).collect::<Vec<TransactionConfirmation>>())
|
||||
}
|
||||
|
||||
fn confirm_transaction(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params::<(U256, TransactionModification, String)>(params).and_then(
|
||||
|(id, modification, pass)| {
|
||||
let id = id.into();
|
||||
let accounts = take_weak!(self.accounts);
|
||||
let queue = take_weak!(self.queue);
|
||||
let client = take_weak!(self.client);
|
||||
@@ -74,7 +74,7 @@ impl<C: 'static, M: 'static> PersonalSigner for SignerClient<C, M> where C: Mini
|
||||
let mut request = confirmation.transaction;
|
||||
// apply modification
|
||||
if let Some(gas_price) = modification.gas_price {
|
||||
request.gas_price = Some(gas_price);
|
||||
request.gas_price = Some(gas_price.into());
|
||||
}
|
||||
|
||||
let sender = request.from;
|
||||
@@ -99,7 +99,7 @@ impl<C: 'static, M: 'static> PersonalSigner for SignerClient<C, M> where C: Mini
|
||||
from_params::<(U256, )>(params).and_then(
|
||||
|(id, )| {
|
||||
let queue = take_weak!(self.queue);
|
||||
let res = queue.request_rejected(id);
|
||||
let res = queue.request_rejected(id.into());
|
||||
to_value(&res.is_some())
|
||||
}
|
||||
)
|
||||
|
||||
@@ -19,12 +19,13 @@
|
||||
use std::sync::{Weak, Arc};
|
||||
use jsonrpc_core::*;
|
||||
use std::collections::BTreeMap;
|
||||
use util::H256;
|
||||
//use util::H256;
|
||||
use ethcore::client::{BlockChainClient, CallAnalytics, TransactionID, TraceId};
|
||||
use ethcore::miner::MinerService;
|
||||
use ethcore::transaction::{Transaction as EthTransaction, SignedTransaction, Action};
|
||||
use v1::traits::Traces;
|
||||
use v1::types::{TraceFilter, LocalizedTrace, Trace, BlockNumber, Index, CallRequest, Bytes, StateDiff, VMTrace};
|
||||
use v1::helpers::CallRequest as CRequest;
|
||||
use v1::types::{TraceFilter, LocalizedTrace, Trace, BlockNumber, Index, CallRequest, Bytes, StateDiff, VMTrace, H256};
|
||||
|
||||
/// Traces api implementation.
|
||||
pub struct TracesClient<C, M> where C: BlockChainClient, M: MinerService {
|
||||
@@ -42,7 +43,7 @@ impl<C, M> TracesClient<C, M> where C: BlockChainClient, M: MinerService {
|
||||
}
|
||||
|
||||
// TODO: share with eth.rs
|
||||
fn sign_call(&self, request: CallRequest) -> Result<SignedTransaction, Error> {
|
||||
fn sign_call(&self, request: CRequest) -> Result<SignedTransaction, Error> {
|
||||
let client = take_weak!(self.client);
|
||||
let miner = take_weak!(self.miner);
|
||||
let from = request.from.unwrap_or(0.into());
|
||||
@@ -91,7 +92,7 @@ impl<C, M> Traces for TracesClient<C, M> where C: BlockChainClient + 'static, M:
|
||||
from_params::<(H256,)>(params)
|
||||
.and_then(|(transaction_hash,)| {
|
||||
let client = take_weak!(self.client);
|
||||
let traces = client.transaction_traces(TransactionID::Hash(transaction_hash));
|
||||
let traces = client.transaction_traces(TransactionID::Hash(transaction_hash.into()));
|
||||
let traces = traces.map_or_else(Vec::new, |traces| traces.into_iter().map(LocalizedTrace::from).collect());
|
||||
to_value(&traces)
|
||||
})
|
||||
@@ -103,7 +104,7 @@ impl<C, M> Traces for TracesClient<C, M> where C: BlockChainClient + 'static, M:
|
||||
.and_then(|(transaction_hash, address)| {
|
||||
let client = take_weak!(self.client);
|
||||
let id = TraceId {
|
||||
transaction: TransactionID::Hash(transaction_hash),
|
||||
transaction: TransactionID::Hash(transaction_hash.into()),
|
||||
address: address.into_iter().map(|i| i.value()).collect()
|
||||
};
|
||||
let trace = client.trace(id);
|
||||
@@ -117,6 +118,7 @@ impl<C, M> Traces for TracesClient<C, M> where C: BlockChainClient + 'static, M:
|
||||
trace!(target: "jsonrpc", "call: {:?}", params);
|
||||
from_params(params)
|
||||
.and_then(|(request, flags)| {
|
||||
let request = CallRequest::into(request);
|
||||
let flags: Vec<String> = flags;
|
||||
let analytics = CallAnalytics {
|
||||
transaction_tracing: flags.contains(&("trace".to_owned())),
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
use jsonrpc_core::*;
|
||||
use util::version;
|
||||
use v1::traits::Web3;
|
||||
use v1::types::Bytes;
|
||||
use v1::types::{H256, Bytes};
|
||||
use util::sha3::Hashable;
|
||||
|
||||
/// Web3 rpc implementation.
|
||||
@@ -40,9 +40,9 @@ impl Web3 for Web3Client {
|
||||
fn sha3(&self, params: Params) -> Result<Value, Error> {
|
||||
from_params::<(Bytes,)>(params).and_then(
|
||||
|(data,)| {
|
||||
let Bytes(ref v) = data;
|
||||
let sha3 = v.sha3();
|
||||
to_value(&sha3)
|
||||
let Bytes(ref vec) = data;
|
||||
let sha3 = vec.sha3();
|
||||
to_value(&H256::from(sha3))
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user