Merge branch 'master' of github.com:ethcore/parity into move_hash
This commit is contained in:
@@ -33,16 +33,18 @@ pub struct PersonalClient<C, M> where C: MiningBlockChainClient, M: MinerService
|
||||
client: Weak<C>,
|
||||
miner: Weak<M>,
|
||||
signer_port: Option<u16>,
|
||||
allow_perm_unlock: bool,
|
||||
}
|
||||
|
||||
impl<C, M> PersonalClient<C, M> where C: MiningBlockChainClient, M: MinerService {
|
||||
/// Creates new PersonalClient
|
||||
pub fn new(store: &Arc<AccountProvider>, client: &Arc<C>, miner: &Arc<M>, signer_port: Option<u16>) -> Self {
|
||||
pub fn new(store: &Arc<AccountProvider>, client: &Arc<C>, miner: &Arc<M>, signer_port: Option<u16>, allow_perm_unlock: bool) -> Self {
|
||||
PersonalClient {
|
||||
accounts: Arc::downgrade(store),
|
||||
client: Arc::downgrade(client),
|
||||
miner: Arc::downgrade(miner),
|
||||
signer_port: signer_port,
|
||||
allow_perm_unlock: allow_perm_unlock,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,11 +91,17 @@ 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::<(RpcH160, String, u64)>(params).and_then(
|
||||
|(account, account_pass, _)|{
|
||||
from_params::<(RpcH160, String, Option<u64>)>(params).and_then(
|
||||
|(account, account_pass, duration)|{
|
||||
let account: Address = account.into();
|
||||
let store = take_weak!(self.accounts);
|
||||
match store.unlock_account_temporarily(account, account_pass) {
|
||||
let r = match (self.allow_perm_unlock, duration) {
|
||||
(false, _) => store.unlock_account_temporarily(account, account_pass),
|
||||
(true, Some(0)) => store.unlock_account_permanently(account, account_pass),
|
||||
(true, Some(d)) => store.unlock_account_timed(account, account_pass, d as u32 * 1000),
|
||||
(true, None) => store.unlock_account_timed(account, account_pass, 300_000),
|
||||
};
|
||||
match r {
|
||||
Ok(_) => Ok(Value::Bool(true)),
|
||||
Err(_) => Ok(Value::Bool(false)),
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ fn sync_provider() -> Arc<TestSyncProvider> {
|
||||
}))
|
||||
}
|
||||
|
||||
fn miner_service(spec: Spec, accounts: Arc<AccountProvider>) -> Arc<Miner> {
|
||||
fn miner_service(spec: &Spec, accounts: Arc<AccountProvider>) -> Arc<Miner> {
|
||||
Miner::new(
|
||||
MinerOptions {
|
||||
new_work_notify: vec![],
|
||||
@@ -65,8 +65,8 @@ fn miner_service(spec: Spec, accounts: Arc<AccountProvider>) -> Arc<Miner> {
|
||||
enable_resubmission: true,
|
||||
},
|
||||
GasPricer::new_fixed(20_000_000_000u64.into()),
|
||||
spec,
|
||||
Some(accounts)
|
||||
&spec,
|
||||
Some(accounts),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ struct EthTester {
|
||||
|
||||
impl EthTester {
|
||||
fn from_chain(chain: &BlockChain) -> Self {
|
||||
let tester = Self::from_spec_provider(|| make_spec(chain));
|
||||
let tester = Self::from_spec(make_spec(chain));
|
||||
|
||||
for b in &chain.blocks_rlp() {
|
||||
if Block::is_good(&b) {
|
||||
@@ -105,13 +105,11 @@ impl EthTester {
|
||||
tester
|
||||
}
|
||||
|
||||
fn from_spec_provider<F>(spec_provider: F) -> Self
|
||||
where F: Fn() -> Spec {
|
||||
|
||||
fn from_spec(spec: Spec) -> Self {
|
||||
let dir = RandomTempPath::new();
|
||||
let account_provider = account_provider();
|
||||
let miner_service = miner_service(spec_provider(), account_provider.clone());
|
||||
let client = Client::new(ClientConfig::default(), spec_provider(), dir.as_path(), miner_service.clone(), IoChannel::disconnected()).unwrap();
|
||||
let miner_service = miner_service(&spec, account_provider.clone());
|
||||
let client = Client::new(ClientConfig::default(), &spec, dir.as_path(), miner_service.clone(), IoChannel::disconnected()).unwrap();
|
||||
let sync_provider = sync_provider();
|
||||
let external_miner = Arc::new(ExternalMiner::default());
|
||||
|
||||
@@ -291,7 +289,7 @@ fn eth_transaction_count() {
|
||||
use util::crypto::Secret;
|
||||
|
||||
let secret = Secret::from_str("8a283037bb19c4fed7b1c569e40c7dcff366165eb869110a1b11532963eb9cb2").unwrap();
|
||||
let tester = EthTester::from_spec_provider(|| Spec::load(TRANSACTION_COUNT_SPEC));
|
||||
let tester = EthTester::from_spec(Spec::load(TRANSACTION_COUNT_SPEC));
|
||||
let address = tester.accounts.insert_account(secret, "").unwrap();
|
||||
tester.accounts.unlock_account_permanently(address, "".into()).unwrap();
|
||||
|
||||
@@ -417,7 +415,7 @@ fn verify_transaction_counts(name: String, chain: BlockChain) {
|
||||
|
||||
#[test]
|
||||
fn starting_nonce_test() {
|
||||
let tester = EthTester::from_spec_provider(|| Spec::load(POSITIVE_NONCE_SPEC));
|
||||
let tester = EthTester::from_spec(Spec::load(POSITIVE_NONCE_SPEC));
|
||||
let address = ::util::hash::Address::from(10);
|
||||
|
||||
let sample = tester.handler.handle_request(&(r#"
|
||||
|
||||
@@ -50,7 +50,7 @@ fn setup(signer: Option<u16>) -> PersonalTester {
|
||||
let accounts = accounts_provider();
|
||||
let client = blockchain_client();
|
||||
let miner = miner_service();
|
||||
let personal = PersonalClient::new(&accounts, &client, &miner, signer);
|
||||
let personal = PersonalClient::new(&accounts, &client, &miner, signer, false);
|
||||
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(personal.to_delegate());
|
||||
|
||||
Reference in New Issue
Block a user