reth_network/transactions/
config.rsuse super::{
DEFAULT_MAX_COUNT_TRANSACTIONS_SEEN_BY_PEER,
DEFAULT_SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESP_ON_PACK_GET_POOLED_TRANSACTIONS_REQ,
SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESPONSE,
};
use crate::transactions::constants::tx_fetcher::{
DEFAULT_MAX_CAPACITY_CACHE_PENDING_FETCH, DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS,
DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS_PER_PEER,
};
use derive_more::Constructor;
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct TransactionsManagerConfig {
pub transaction_fetcher_config: TransactionFetcherConfig,
pub max_transactions_seen_by_peer_history: u32,
#[cfg_attr(feature = "serde", serde(default))]
pub propagation_mode: TransactionPropagationMode,
}
impl Default for TransactionsManagerConfig {
fn default() -> Self {
Self {
transaction_fetcher_config: TransactionFetcherConfig::default(),
max_transactions_seen_by_peer_history: DEFAULT_MAX_COUNT_TRANSACTIONS_SEEN_BY_PEER,
propagation_mode: TransactionPropagationMode::default(),
}
}
}
#[derive(Debug, Clone, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum TransactionPropagationMode {
#[default]
Sqrt,
All,
Max(usize),
}
impl TransactionPropagationMode {
pub(crate) fn full_peer_count(&self, peer_count: usize) -> usize {
match self {
Self::Sqrt => (peer_count as f64).sqrt().round() as usize,
Self::All => peer_count,
Self::Max(max) => peer_count.min(*max),
}
}
}
#[derive(Debug, Constructor, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct TransactionFetcherConfig {
pub max_inflight_requests: u32,
pub max_inflight_requests_per_peer: u8,
pub soft_limit_byte_size_pooled_transactions_response: usize,
pub soft_limit_byte_size_pooled_transactions_response_on_pack_request: usize,
pub max_capacity_cache_txns_pending_fetch: u32,
}
impl Default for TransactionFetcherConfig {
fn default() -> Self {
Self {
max_inflight_requests: DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS,
max_inflight_requests_per_peer: DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS_PER_PEER,
soft_limit_byte_size_pooled_transactions_response:
SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESPONSE,
soft_limit_byte_size_pooled_transactions_response_on_pack_request:
DEFAULT_SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESP_ON_PACK_GET_POOLED_TRANSACTIONS_REQ,
max_capacity_cache_txns_pending_fetch: DEFAULT_MAX_CAPACITY_CACHE_PENDING_FETCH,
}
}
}