Extracted TransactionsManagerConfig creation as a standalone function (#14645)

This commit is contained in:
Poulav Bhowmick
2025-02-22 13:04:10 +05:30
committed by GitHub
parent 25db3b12e6
commit 9cb2a1e556

View File

@ -184,6 +184,20 @@ impl NetworkArgs {
bootnodes.into_iter().filter_map(|node| node.resolve_blocking().ok()).collect()
})
}
/// Configures and returns a `TransactionsManagerConfig` based on the current settings.
pub fn transactions_manager_config(&self) -> TransactionsManagerConfig {
TransactionsManagerConfig {
transaction_fetcher_config: TransactionFetcherConfig::new(
self.max_concurrent_tx_requests,
self.max_concurrent_tx_requests_per_peer,
self.soft_limit_byte_size_pooled_transactions_response,
self.soft_limit_byte_size_pooled_transactions_response_on_pack_request,
self.max_capacity_cache_txns_pending_fetch,
),
max_transactions_seen_by_peer_history: self.max_seen_tx_history,
propagation_mode: Default::default(),
}
}
/// Build a [`NetworkConfigBuilder`] from a [`Config`] and a [`EthChainSpec`], in addition to
/// the values in this option struct.
@ -216,19 +230,6 @@ impl NetworkArgs {
.with_max_inbound_opt(self.max_inbound_peers)
.with_max_outbound_opt(self.max_outbound_peers);
// Configure transactions manager
let transactions_manager_config = TransactionsManagerConfig {
transaction_fetcher_config: TransactionFetcherConfig::new(
self.max_concurrent_tx_requests,
self.max_concurrent_tx_requests_per_peer,
self.soft_limit_byte_size_pooled_transactions_response,
self.soft_limit_byte_size_pooled_transactions_response_on_pack_request,
self.max_capacity_cache_txns_pending_fetch,
),
max_transactions_seen_by_peer_history: self.max_seen_tx_history,
propagation_mode: Default::default(),
};
// Configure basic network stack
NetworkConfigBuilder::<N>::new(secret_key)
.peer_config(config.peers_config_with_basic_nodes_from_file(
@ -240,7 +241,7 @@ impl NetworkArgs {
)
.peer_config(peers_config)
.boot_nodes(chain_bootnodes.clone())
.transactions_manager_config(transactions_manager_config)
.transactions_manager_config(self.transactions_manager_config())
// Configure node identity
.apply(|builder| {
let peer_id = builder.get_peer_id();