Limit the number of transactions in pending set (#8777)
* Unordered iterator. * Use unordered and limited set if full not required. * Split timeout work into smaller timers. * Avoid collecting all pending transactions when mining * Remove println. * Use priority ordering in eth-filter. * Fix ethcore-miner tests and tx propagation. * Review grumbles addressed. * Add test for unordered not populating the cache. * Fix ethcore tests. * Fix light tests. * Fix ethcore-sync tests. * Fix RPC tests.
This commit is contained in:
committed by
Marek Kotewicz
parent
4817b94d0b
commit
4938d5dde5
@@ -85,7 +85,7 @@ impl<C, M> Filterable for EthFilterClient<C, M> where
|
||||
}
|
||||
|
||||
fn pending_transactions_hashes(&self) -> Vec<H256> {
|
||||
self.miner.ready_transactions(&*self.client)
|
||||
self.miner.ready_transactions(&*self.client, usize::max_value(), miner::PendingOrdering::Priority)
|
||||
.into_iter()
|
||||
.map(|tx| tx.signed().hash())
|
||||
.collect()
|
||||
|
||||
@@ -175,7 +175,7 @@ impl<C> ChainNotificationHandler<C> {
|
||||
}
|
||||
|
||||
/// Notify all subscribers about new transaction hashes.
|
||||
pub fn new_transactions(&self, hashes: &[H256]) {
|
||||
pub fn notify_new_transactions(&self, hashes: &[H256]) {
|
||||
for subscriber in self.transactions_subscribers.read().values() {
|
||||
for hash in hashes {
|
||||
Self::notify(&self.remote, subscriber, pubsub::Result::TransactionHash((*hash).into()));
|
||||
|
||||
@@ -264,12 +264,13 @@ impl Parity for ParityClient {
|
||||
.map(Into::into)
|
||||
}
|
||||
|
||||
fn pending_transactions(&self) -> Result<Vec<Transaction>> {
|
||||
fn pending_transactions(&self, limit: Trailing<usize>) -> Result<Vec<Transaction>> {
|
||||
let txq = self.light_dispatch.transaction_queue.read();
|
||||
let chain_info = self.light_dispatch.client.chain_info();
|
||||
Ok(
|
||||
txq.ready_transactions(chain_info.best_block_number, chain_info.best_block_timestamp)
|
||||
.into_iter()
|
||||
.take(limit.unwrap_or_else(usize::max_value))
|
||||
.map(|tx| Transaction::from_pending(tx, chain_info.best_block_number, self.eip86_transition))
|
||||
.collect::<Vec<_>>()
|
||||
)
|
||||
|
||||
@@ -303,15 +303,19 @@ impl<C, M, U, S> Parity for ParityClient<C, M, U> where
|
||||
.map(Into::into)
|
||||
}
|
||||
|
||||
fn pending_transactions(&self) -> Result<Vec<Transaction>> {
|
||||
fn pending_transactions(&self, limit: Trailing<usize>) -> Result<Vec<Transaction>> {
|
||||
let block_number = self.client.chain_info().best_block_number;
|
||||
let ready_transactions = self.miner.ready_transactions(&*self.client);
|
||||
let ready_transactions = self.miner.ready_transactions(
|
||||
&*self.client,
|
||||
limit.unwrap_or_else(usize::max_value),
|
||||
miner::PendingOrdering::Priority,
|
||||
);
|
||||
|
||||
Ok(ready_transactions
|
||||
.into_iter()
|
||||
.map(|t| Transaction::from_pending(t.pending().clone(), block_number, self.eip86_transition))
|
||||
.collect()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fn all_transactions(&self) -> Result<Vec<Transaction>> {
|
||||
|
||||
Reference in New Issue
Block a user