Merge branch 'master' into txtracingforcall
This commit is contained in:
@@ -499,7 +499,7 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM> where
|
||||
.and_then(|(raw_transaction, )| {
|
||||
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),
|
||||
Ok(signed_transaction) => to_value(&dispatch_transaction(&*take_weak!(self.client), &*take_weak!(self.miner), signed_transaction)),
|
||||
Err(_) => to_value(&H256::zero()),
|
||||
}
|
||||
})
|
||||
|
||||
@@ -53,9 +53,9 @@ impl EthSigning for EthSigningQueueClient {
|
||||
from_params::<(TransactionRequest, )>(params)
|
||||
.and_then(|(request, )| {
|
||||
let queue = take_weak!(self.queue);
|
||||
queue.add_request(request);
|
||||
// TODO [ToDr] Block and wait for confirmation?
|
||||
to_value(&H256::zero())
|
||||
let id = queue.add_request(request);
|
||||
let result = id.wait_with_timeout();
|
||||
to_value(&result.unwrap_or_else(H256::new))
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ impl<C, A, M> EthSigning for EthSigningUnsafeClient<C, A, M> where
|
||||
.and_then(|(request, )| {
|
||||
let accounts = take_weak!(self.accounts);
|
||||
match accounts.account_secret(&request.from) {
|
||||
Ok(secret) => sign_and_dispatch(&self.client, &self.miner, request, secret),
|
||||
Ok(secret) => to_value(&sign_and_dispatch(&*take_weak!(self.client), &*take_weak!(self.miner), request, secret)),
|
||||
Err(_) => to_value(&H256::zero())
|
||||
}
|
||||
})
|
||||
|
||||
@@ -52,16 +52,14 @@ pub use self::traces::TracesClient;
|
||||
pub use self::rpc::RpcClient;
|
||||
|
||||
use v1::types::TransactionRequest;
|
||||
use std::sync::Weak;
|
||||
use ethcore::miner::{AccountDetails, MinerService};
|
||||
use ethcore::client::MiningBlockChainClient;
|
||||
use ethcore::transaction::{Action, SignedTransaction, Transaction};
|
||||
use util::numbers::*;
|
||||
use util::rlp::encode;
|
||||
use util::bytes::ToPretty;
|
||||
use jsonrpc_core::{Error, to_value, Value};
|
||||
|
||||
fn dispatch_transaction<C, M>(client: &C, miner: &M, signed_transaction: SignedTransaction) -> Result<Value, Error>
|
||||
fn dispatch_transaction<C, M>(client: &C, miner: &M, signed_transaction: SignedTransaction) -> H256
|
||||
where C: MiningBlockChainClient, M: MinerService {
|
||||
let hash = signed_transaction.hash();
|
||||
|
||||
@@ -72,13 +70,11 @@ fn dispatch_transaction<C, M>(client: &C, miner: &M, signed_transaction: SignedT
|
||||
}
|
||||
});
|
||||
|
||||
to_value(&import.map(|_| hash).unwrap_or(H256::zero()))
|
||||
import.map(|_| hash).unwrap_or(H256::zero())
|
||||
}
|
||||
|
||||
fn sign_and_dispatch<C, M>(client: &Weak<C>, miner: &Weak<M>, request: TransactionRequest, secret: H256) -> Result<Value, Error>
|
||||
fn sign_and_dispatch<C, M>(client: &C, miner: &M, request: TransactionRequest, secret: H256) -> H256
|
||||
where C: MiningBlockChainClient, M: MinerService {
|
||||
let client = take_weak!(client);
|
||||
let miner = take_weak!(miner);
|
||||
|
||||
let signed_transaction = {
|
||||
Transaction {
|
||||
|
||||
@@ -83,7 +83,7 @@ impl<A: 'static, C: 'static, M: 'static> Personal for PersonalClient<A, C, M>
|
||||
.and_then(|(request, password)| {
|
||||
let accounts = take_weak!(self.accounts);
|
||||
match accounts.locked_account_secret(&request.from, &password) {
|
||||
Ok(secret) => sign_and_dispatch(&self.client, &self.miner, request, secret),
|
||||
Ok(secret) => to_value(&sign_and_dispatch(&*take_weak!(self.client), &*take_weak!(self.miner), request, secret)),
|
||||
Err(_) => to_value(&H256::zero()),
|
||||
}
|
||||
})
|
||||
|
||||
@@ -63,19 +63,27 @@ impl<A: 'static, C: 'static, M: 'static> PersonalSigner for SignerClient<A, C, M
|
||||
|(id, modification, pass)| {
|
||||
let accounts = take_weak!(self.accounts);
|
||||
let queue = take_weak!(self.queue);
|
||||
queue.remove_request(id)
|
||||
.and_then(|confirmation| {
|
||||
let client = take_weak!(self.client);
|
||||
let miner = take_weak!(self.miner);
|
||||
queue.peek(&id).and_then(|confirmation| {
|
||||
let mut request = confirmation.transaction;
|
||||
// apply modification
|
||||
if let Some(gas_price) = modification.gas_price {
|
||||
request.gas_price = Some(gas_price);
|
||||
}
|
||||
match accounts.locked_account_secret(&request.from, &pass) {
|
||||
Ok(secret) => Some(sign_and_dispatch(&self.client, &self.miner, request, secret)),
|
||||
Ok(secret) => {
|
||||
let hash = sign_and_dispatch(&*client, &*miner, request, secret);
|
||||
queue.request_confirmed(id, hash);
|
||||
Some(to_value(&hash))
|
||||
},
|
||||
Err(_) => None
|
||||
}
|
||||
})
|
||||
.unwrap_or_else(|| to_value(&H256::zero()))
|
||||
.unwrap_or_else(|| {
|
||||
queue.request_rejected(id);
|
||||
to_value(&H256::zero())
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -84,7 +92,7 @@ impl<A: 'static, C: 'static, M: 'static> PersonalSigner for SignerClient<A, C, M
|
||||
from_params::<(U256, )>(params).and_then(
|
||||
|(id, )| {
|
||||
let queue = take_weak!(self.queue);
|
||||
let res = queue.remove_request(id);
|
||||
let res = queue.request_rejected(id);
|
||||
to_value(&res.is_some())
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user