Merge branch 'master' into rotating-key

Conflicts:
	ethcore/src/account_provider/mod.rs
	rpc/src/v1/types/mod.rs.in
This commit is contained in:
Tomasz Drwięga
2016-12-09 07:37:34 +00:00
342 changed files with 10048 additions and 4061 deletions

View File

@@ -20,7 +20,6 @@ extern crate ethash;
use std::io::{Write};
use std::process::{Command, Stdio};
use std::collections::BTreeSet;
use std::thread;
use std::time::{Instant, Duration};
use std::sync::{Arc, Weak};
@@ -46,7 +45,7 @@ use self::ethash::SeedHashCompute;
use v1::traits::Eth;
use v1::types::{
RichBlock, Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, SyncInfo,
Transaction, CallRequest, Index, Filter, Log, Receipt, Work,
Transaction, CallRequest, Index, Filter, Log, Receipt, Work, DappId,
H64 as RpcH64, H256 as RpcH256, H160 as RpcH160, U256 as RpcU256,
};
use v1::helpers::{CallRequest as CRequest, errors, limit_logs};
@@ -335,15 +334,15 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
Ok(RpcU256::from(default_gas_price(&*client, &*miner)))
}
fn accounts(&self) -> Result<Vec<RpcH160>, Error> {
fn accounts(&self, id: Trailing<DappId>) -> Result<Vec<RpcH160>, Error> {
try!(self.active());
let store = take_weak!(self.accounts);
let accounts = try!(store.accounts().map_err(|e| errors::internal("Could not fetch accounts.", e)));
let addresses = try!(store.addresses_info().map_err(|e| errors::internal("Could not fetch accounts.", e)));
let dapp = id.0;
let set: BTreeSet<Address> = accounts.into_iter().chain(addresses.keys().cloned()).collect();
Ok(set.into_iter().map(Into::into).collect())
let store = take_weak!(self.accounts);
let accounts = try!(store.dapps_addresses(dapp.into()).map_err(|e| errors::internal("Could not fetch accounts.", e)));
Ok(accounts.into_iter().map(Into::into).collect())
}
fn block_number(&self) -> Result<RpcU256, Error> {

View File

@@ -25,7 +25,7 @@ use ethcore::client::MiningBlockChainClient;
use jsonrpc_core::{Value, Error, to_value};
use v1::traits::ParityAccounts;
use v1::types::{H160 as RpcH160, H256 as RpcH256};
use v1::types::{H160 as RpcH160, H256 as RpcH256, DappId};
use v1::helpers::errors;
/// Account management (personal) rpc implementation.
@@ -57,7 +57,7 @@ impl<C: 'static> ParityAccounts for ParityAccountsClient<C> where C: MiningBlock
let info = try!(store.accounts_info().map_err(|e| errors::account("Could not fetch account info.", e)));
let other = store.addresses_info().expect("addresses_info always returns Ok; qed");
Ok(info.into_iter().chain(other.into_iter()).map(|(a, v)| {
Ok(other.into_iter().chain(info.into_iter()).map(|(a, v)| {
let m = map![
"name".to_owned() => to_value(&v.name),
"meta".to_owned() => to_value(&v.meta),
@@ -126,6 +126,16 @@ impl<C: 'static> ParityAccounts for ParityAccountsClient<C> where C: MiningBlock
.map_err(|e| errors::account("Could not delete account.", e))
}
fn remove_address(&self, addr: RpcH160) -> Result<bool, Error> {
try!(self.active());
let store = take_weak!(self.accounts);
let addr: Address = addr.into();
store.remove_address(addr)
.expect("remove_address always returns Ok; qed");
Ok(true)
}
fn set_account_name(&self, addr: RpcH160, name: String) -> Result<bool, Error> {
try!(self.active());
let store = take_weak!(self.accounts);
@@ -152,6 +162,15 @@ impl<C: 'static> ParityAccounts for ParityAccountsClient<C> where C: MiningBlock
Ok(false)
}
fn set_dapps_addresses(&self, dapp: DappId, addresses: Vec<RpcH160>) -> Result<bool, Error> {
let store = take_weak!(self.accounts);
let addresses = addresses.into_iter().map(Into::into).collect();
store.set_dapps_addresses(dapp.into(), addresses)
.map_err(|e| errors::account("Couldn't set dapps addresses.", e))
.map(|_| true)
}
fn import_geth_accounts(&self, addresses: Vec<RpcH160>) -> Result<Vec<RpcH160>, Error> {
let store = take_weak!(self.accounts);

View File

@@ -116,6 +116,12 @@ impl<C, M, F> ParitySet for ParitySetClient<C, M, F> where
Ok(true)
}
fn set_engine_signer(&self, address: H160, password: String) -> Result<bool, Error> {
try!(self.active());
try!(take_weak!(self.miner).set_engine_signer(address.into(), password).map_err(Into::into).map_err(errors::from_password_error));
Ok(true)
}
fn set_transactions_limit(&self, limit: usize) -> Result<bool, Error> {
try!(self.active());