Add filtering capability to parity_pendingTransactions (issue 8269) (#10506)
* expand parameters for pending_transactions() * move ready_transactions content into filtered method * apply filter based on tx_hash, sender or receiver * call filtered transactions from RPC interface * attempt at testing... * replace parameters with _ on light client * addes some comments * removed uncompleted tests in miner.rs * attempt at testing, needs more work... * Formatting for ready_transactions_filtered Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Use map_or instead of if-let Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * additional map_or replacement * change receiver type to Option<Option<Address>> * remove faulty MiningService tests, test RPC later * remove tx hash from pending transaction filtering * as_unsigned() method for SignedTransaction * implement Deserialize for FilterOptions * implement Validate for MapAccess type * additional formatting * directly name cover in pattern matching * test valid vull deserialization * test valid sender operators * test valid receiver operators * test valid gas operators * test valid gas price operators * test valid value operators * test valid nonce operators * additional tsets for defaults, unknown filter types, unknown operators and some renames * move filter_options to ethcore to avoid package cycling * adjusted function/method parameters for FilterOptions * implement filter for sender and receiver * implement filter for gas * implement filter for gas price, tx value and nonce * improve filtering implementation; use common function, use combinators * improved documentation for FilterOptions * small documentation adjustments * remove warnings * replace FilterOperator::ContractCreation with FilterOperator::Eq(None) * implement validate_receiver * make small changes like renames, preamble * cleanup code according to suggestions, add docs * small improvements like formatting and newline
This commit is contained in:
@@ -26,6 +26,7 @@ use ethstore::random_phrase;
|
||||
use sync::{LightSyncInfo, LightSyncProvider, LightNetworkDispatcher, ManageNetwork};
|
||||
use updater::VersionInfo as UpdaterVersionInfo;
|
||||
use ethereum_types::{H64, H160, H256, H512, U64, U256};
|
||||
use ethcore::miner::FilterOptions;
|
||||
use ethcore_logger::RotatingLogger;
|
||||
|
||||
use jsonrpc_core::{Result, BoxFuture};
|
||||
@@ -217,7 +218,7 @@ where
|
||||
.map(Into::into)
|
||||
}
|
||||
|
||||
fn pending_transactions(&self, limit: Option<usize>) -> Result<Vec<Transaction>> {
|
||||
fn pending_transactions(&self, limit: Option<usize>, _filter: Option<FilterOptions>) -> Result<Vec<Transaction>> {
|
||||
let txq = self.light_dispatch.transaction_queue.read();
|
||||
let chain_info = self.light_dispatch.client.chain_info();
|
||||
Ok(
|
||||
|
||||
@@ -22,7 +22,7 @@ use std::collections::BTreeMap;
|
||||
use crypto::DEFAULT_MAC;
|
||||
use ethereum_types::{Address, H64, H160, H256, H512, U64, U256};
|
||||
use ethcore::client::{BlockChainClient, StateClient, Call};
|
||||
use ethcore::miner::{self, MinerService};
|
||||
use ethcore::miner::{self, MinerService, FilterOptions};
|
||||
use ethcore::snapshot::{SnapshotService, RestorationStatus};
|
||||
use ethcore::state::StateInfo;
|
||||
use ethcore_logger::RotatingLogger;
|
||||
@@ -245,10 +245,11 @@ impl<C, M, U, S> Parity for ParityClient<C, M, U> where
|
||||
.map(Into::into)
|
||||
}
|
||||
|
||||
fn pending_transactions(&self, limit: Option<usize>) -> Result<Vec<Transaction>> {
|
||||
let ready_transactions = self.miner.ready_transactions(
|
||||
fn pending_transactions(&self, limit: Option<usize>, filter: Option<FilterOptions>) -> Result<Vec<Transaction>> {
|
||||
let ready_transactions = self.miner.ready_transactions_filtered(
|
||||
&*self.client,
|
||||
limit.unwrap_or_else(usize::max_value),
|
||||
filter,
|
||||
miner::PendingOrdering::Priority,
|
||||
);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ use ethcore::block::SealedBlock;
|
||||
use ethcore::client::{Nonce, PrepareOpenBlock, StateClient, EngineInfo};
|
||||
use ethcore::engines::{Engine, signer::EngineSigner};
|
||||
use ethcore::error::Error;
|
||||
use ethcore::miner::{self, MinerService, AuthoringParams};
|
||||
use ethcore::miner::{self, MinerService, AuthoringParams, FilterOptions};
|
||||
use ethereum_types::{H256, U256, Address};
|
||||
use miner::pool::local_transactions::Status as LocalTransactionStatus;
|
||||
use miner::pool::{verifier, VerifiedTransaction, QueueStatus};
|
||||
@@ -222,6 +222,10 @@ impl MinerService for TestMinerService {
|
||||
self.queued_transactions()
|
||||
}
|
||||
|
||||
fn ready_transactions_filtered<C>(&self, _chain: &C, _max_len: usize, _filter: Option<FilterOptions>, _ordering: miner::PendingOrdering) -> Vec<Arc<VerifiedTransaction>> {
|
||||
self.queued_transactions()
|
||||
}
|
||||
|
||||
fn pending_transaction_hashes<C>(&self, _chain: &C) -> BTreeSet<H256> {
|
||||
self.queued_transactions().into_iter().map(|tx| tx.signed().hash()).collect()
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use ethereum_types::{H64, H160, H256, H512, U64, U256};
|
||||
use ethcore::miner::FilterOptions;
|
||||
use jsonrpc_core::{BoxFuture, Result};
|
||||
use jsonrpc_derive::rpc;
|
||||
use v1::types::{
|
||||
@@ -125,7 +126,7 @@ pub trait Parity {
|
||||
|
||||
/// Returns all pending transactions from transaction queue.
|
||||
#[rpc(name = "parity_pendingTransactions")]
|
||||
fn pending_transactions(&self, Option<usize>) -> Result<Vec<Transaction>>;
|
||||
fn pending_transactions(&self, Option<usize>, Option<FilterOptions>) -> Result<Vec<Transaction>>;
|
||||
|
||||
/// Returns all transactions from transaction queue.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user