fixed pending transactions

This commit is contained in:
debris 2016-05-26 11:39:49 +02:00
parent 32298cad6b
commit f811fdc2cd

View File

@ -672,18 +672,22 @@ impl<C, M> EthFilter for EthFilterClient<C, M> where
to_value(&hashes) to_value(&hashes)
}, },
PollFilter::PendingTransaction(ref mut previous_hashes) => { PollFilter::PendingTransaction(ref mut previous_hashes) => {
// get hashes of pending transactions
let current_hashes = take_weak!(self.miner).pending_transactions_hashes(); let current_hashes = take_weak!(self.miner).pending_transactions_hashes();
// calculate diff
let previous_hashes_set = previous_hashes.into_iter().map(|h| h.clone()).collect::<HashSet<H256>>(); let previous_hashes_set = previous_hashes.into_iter().map(|h| h.clone()).collect::<HashSet<H256>>();
let diff = current_hashes
// find all new hashes
let new_hashes = current_hashes
.iter() .iter()
.filter(|hash| previous_hashes_set.contains(&hash)) .filter(|hash| !previous_hashes_set.contains(&hash))
.cloned() .cloned()
.collect::<Vec<H256>>(); .collect::<Vec<H256>>();
// save all hashes of pending transactions
*previous_hashes = current_hashes; *previous_hashes = current_hashes;
to_value(&diff) // return new hashes
to_value(&new_hashes)
}, },
PollFilter::Logs(ref mut block_number, ref mut previous_logs, ref filter) => { PollFilter::Logs(ref mut block_number, ref mut previous_logs, ref filter) => {
// retrive the current block number // retrive the current block number