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
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Transaction Pool
|
||||
|
||||
use ethereum_types::{H256, Address};
|
||||
use ethereum_types::{U256, H256, Address};
|
||||
use heapsize::HeapSizeOf;
|
||||
use transaction;
|
||||
use txpool;
|
||||
@@ -45,6 +45,43 @@ pub enum PrioritizationStrategy {
|
||||
GasPriceOnly,
|
||||
}
|
||||
|
||||
/// Transaction ordering when requesting pending set.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
pub enum PendingOrdering {
|
||||
/// Get pending transactions ordered by their priority (potentially expensive)
|
||||
Priority,
|
||||
/// Get pending transactions without any care of particular ordering (cheaper).
|
||||
Unordered,
|
||||
}
|
||||
|
||||
/// Pending set query settings
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PendingSettings {
|
||||
/// Current block number (affects readiness of some transactions).
|
||||
pub block_number: u64,
|
||||
/// Current timestamp (affects readiness of some transactions).
|
||||
pub current_timestamp: u64,
|
||||
/// Nonce cap (for dust protection; EIP-168)
|
||||
pub nonce_cap: Option<U256>,
|
||||
/// Maximal number of transactions in pending the set.
|
||||
pub max_len: usize,
|
||||
/// Ordering of transactions.
|
||||
pub ordering: PendingOrdering,
|
||||
}
|
||||
|
||||
impl PendingSettings {
|
||||
/// Get all transactions (no cap or len limit) prioritized.
|
||||
pub fn all_prioritized(block_number: u64, current_timestamp: u64) -> Self {
|
||||
PendingSettings {
|
||||
block_number,
|
||||
current_timestamp,
|
||||
nonce_cap: None,
|
||||
max_len: usize::max_value(),
|
||||
ordering: PendingOrdering::Priority,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Transaction priority.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
pub(crate) enum Priority {
|
||||
|
||||
Reference in New Issue
Block a user