From 20a0980a82005ce8925f778c97003b75fe4c51ed Mon Sep 17 00:00:00 2001 From: viquezclaudio Date: Mon, 20 Jun 2022 14:58:58 -0600 Subject: [PATCH] Include control mempool config option Create a new config parameter to limit the amount of transactions that can be kept in the control mempool --- lib/src/config/config.rs | 2 ++ lib/src/config/config_file/mod.rs | 4 ++++ mempool/src/config.rs | 5 ++++- mempool/src/mempool.rs | 5 ++++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/src/config/config.rs b/lib/src/config/config.rs index 99133187b1..577cb7fd43 100644 --- a/lib/src/config/config.rs +++ b/lib/src/config/config.rs @@ -696,11 +696,13 @@ impl ClientConfigBuilder { pub fn mempool( &mut self, size_limit: usize, + control_size_limit: usize, filter_rules: MempoolRules, filter_limit: usize, ) -> &mut Self { self.mempool = Some(MempoolConfig { size_limit, + control_size_limit, filter_rules, filter_limit, }); diff --git a/lib/src/config/config_file/mod.rs b/lib/src/config/config_file/mod.rs index 0eb0455de9..d8a1d04b9d 100644 --- a/lib/src/config/config_file/mod.rs +++ b/lib/src/config/config_file/mod.rs @@ -382,6 +382,7 @@ pub struct DatabaseSettings { pub struct MempoolSettings { pub filter: Option, pub size_limit: Option, + pub control_size_limit: Option, pub blacklist_limit: Option, } @@ -427,6 +428,9 @@ impl From for MempoolConfig { fn from(mempool: MempoolSettings) -> Self { Self { size_limit: mempool.size_limit.unwrap_or(Mempool::DEFAULT_SIZE_LIMIT), + control_size_limit: mempool + .control_size_limit + .unwrap_or(Mempool::DEFAULT_CONTROL_SIZE_LIMIT), filter_limit: mempool .blacklist_limit .unwrap_or(MempoolFilter::DEFAULT_BLACKLIST_SIZE), diff --git a/mempool/src/config.rs b/mempool/src/config.rs index d5ab13f068..b1623277ad 100644 --- a/mempool/src/config.rs +++ b/mempool/src/config.rs @@ -4,8 +4,10 @@ use crate::mempool::Mempool; /// Struct defining a Mempool configuration #[derive(Debug, Clone)] pub struct MempoolConfig { - /// Total size limit of transactions in the mempool (bytes) + /// Total size limit of transactions in the regular mempool (bytes) pub size_limit: usize, + /// Total size limit of transactions in the control mempool (bytes) + pub control_size_limit: usize, /// Mempool filter rules pub filter_rules: MempoolRules, /// Mempool filter limit or size @@ -16,6 +18,7 @@ impl Default for MempoolConfig { fn default() -> MempoolConfig { MempoolConfig { size_limit: Mempool::DEFAULT_SIZE_LIMIT, + control_size_limit: Mempool::DEFAULT_CONTROL_SIZE_LIMIT, filter_rules: MempoolRules::default(), filter_limit: MempoolFilter::DEFAULT_BLACKLIST_SIZE, } diff --git a/mempool/src/mempool.rs b/mempool/src/mempool.rs index 3ab7e32c81..c3888910c8 100644 --- a/mempool/src/mempool.rs +++ b/mempool/src/mempool.rs @@ -73,7 +73,10 @@ pub struct Mempool { impl Mempool { /// Default total size limit of transactions in the mempool (bytes) - pub const DEFAULT_SIZE_LIMIT: usize = 12000000; + pub const DEFAULT_SIZE_LIMIT: usize = 12_000_000; + + /// Default total size limit of control transactions in the mempool (bytes) + pub const DEFAULT_CONTROL_SIZE_LIMIT: usize = 6_000_000; /// Creates a new mempool pub fn new(blockchain: Arc>, config: MempoolConfig) -> Self {