Merge pull request #894 from ethcore/send-transactions

Propagate transaction queue
This commit is contained in:
Arkadiy Paronyan
2016-04-07 15:36:01 +02:00
7 changed files with 29 additions and 36 deletions

View File

@@ -186,7 +186,7 @@ impl<C, S, A, M, EM> EthClient<C, S, A, M, EM>
}.fake_sign(from))
}
fn dispatch_transaction(&self, signed_transaction: SignedTransaction, raw_transaction: Vec<u8>) -> Result<Value, Error> {
fn dispatch_transaction(&self, signed_transaction: SignedTransaction) -> Result<Value, Error> {
let hash = signed_transaction.hash();
let import = {
@@ -203,7 +203,6 @@ impl<C, S, A, M, EM> EthClient<C, S, A, M, EM>
match import.into_iter().collect::<Result<Vec<_>, _>>() {
Ok(_) => {
take_weak!(self.sync).new_transaction(raw_transaction);
to_value(&hash)
}
Err(e) => {
@@ -504,8 +503,7 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
data: request.data.map_or_else(Vec::new, |d| d.to_vec()),
}.sign(&secret)
};
let raw_transaction = encode(&signed_transaction).to_vec();
self.dispatch_transaction(signed_transaction, raw_transaction)
self.dispatch_transaction(signed_transaction)
},
Err(_) => { to_value(&H256::zero()) }
}
@@ -517,7 +515,7 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
.and_then(|(raw_transaction, )| {
let raw_transaction = raw_transaction.to_vec();
match UntrustedRlp::new(&raw_transaction).as_val() {
Ok(signed_transaction) => self.dispatch_transaction(signed_transaction, raw_transaction),
Ok(signed_transaction) => self.dispatch_transaction(signed_transaction),
Err(_) => to_value(&H256::zero()),
}
})

View File

@@ -98,6 +98,10 @@ impl MinerService for TestMinerService {
self.pending_transactions.lock().unwrap().get(hash).cloned()
}
fn pending_transactions(&self) -> Vec<SignedTransaction> {
self.pending_transactions.lock().unwrap().values().cloned().collect()
}
fn last_nonce(&self, address: &Address) -> Option<U256> {
self.last_nonces.read().unwrap().get(address).cloned()
}

View File

@@ -16,7 +16,7 @@
//! Test implementation of SyncProvider.
use util::{U256, Bytes};
use util::{U256};
use ethsync::{SyncProvider, SyncStatus, SyncState};
use std::sync::{RwLock};
@@ -59,8 +59,5 @@ impl SyncProvider for TestSyncProvider {
fn status(&self) -> SyncStatus {
self.status.read().unwrap().clone()
}
fn new_transaction(&self, _raw_transaction: Bytes) {
}
}