From f811fdc2cdfc134c55b1a156d90541bb3111358c Mon Sep 17 00:00:00 2001 From: debris Date: Thu, 26 May 2016 11:39:49 +0200 Subject: [PATCH] fixed pending transactions --- rpc/src/v1/impls/eth.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 4a4ee1643..fc22d2256 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -672,18 +672,22 @@ impl EthFilter for EthFilterClient where to_value(&hashes) }, PollFilter::PendingTransaction(ref mut previous_hashes) => { + // get hashes of pending transactions 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::>(); - let diff = current_hashes + + // find all new hashes + let new_hashes = current_hashes .iter() - .filter(|hash| previous_hashes_set.contains(&hash)) + .filter(|hash| !previous_hashes_set.contains(&hash)) .cloned() .collect::>(); + // save all hashes of pending transactions *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) => { // retrive the current block number