Merge pull request #609 from ethcore/tx-rpc-expose
Expose transaction insertion in sync lib
This commit is contained in:
commit
5764ec5ddc
@ -43,6 +43,7 @@ use io::SyncIo;
|
||||
use transaction_queue::TransactionQueue;
|
||||
use time;
|
||||
use super::SyncConfig;
|
||||
use ethcore;
|
||||
|
||||
known_heap_size!(0, PeerInfo, Header, HeaderId);
|
||||
|
||||
@ -1301,6 +1302,13 @@ impl ChainSync {
|
||||
// TODO [todr] propagate transactions?
|
||||
}
|
||||
|
||||
/// Add transaction to the transaction queue
|
||||
pub fn insert_transaction<T>(&self, transaction: ethcore::transaction::SignedTransaction, fetch_nonce: &T)
|
||||
where T: Fn(&Address) -> U256
|
||||
{
|
||||
let mut queue = self.transaction_queue.lock().unwrap();
|
||||
queue.add(transaction, fetch_nonce);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -129,6 +129,15 @@ impl EthSync {
|
||||
pub fn restart(&mut self, io: &mut NetworkContext<SyncMessage>) {
|
||||
self.sync.write().unwrap().restart(&mut NetSyncIo::new(io, self.chain.deref()));
|
||||
}
|
||||
|
||||
/// Insert transaction in transaction queue
|
||||
pub fn insert_transaction(&self, transaction: ethcore::transaction::SignedTransaction) {
|
||||
use util::numbers::*;
|
||||
|
||||
let nonce_fn = |a: &Address| self.chain.state().nonce(a) + U256::one();
|
||||
let sync = self.sync.write().unwrap();
|
||||
sync.insert_transaction(transaction, &nonce_fn);
|
||||
}
|
||||
}
|
||||
|
||||
impl NetworkProtocolHandler<SyncMessage> for EthSync {
|
||||
|
Loading…
Reference in New Issue
Block a user