Skip to content

Commit

Permalink
Include control mempool config option
Browse files Browse the repository at this point in the history
Create a new config parameter to limit the amount of transactions
that can be kept in the control mempool
  • Loading branch information
viquezclaudio committed Jul 5, 2022
1 parent 703b0bb commit 20a0980
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/src/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
4 changes: 4 additions & 0 deletions lib/src/config/config_file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ pub struct DatabaseSettings {
pub struct MempoolSettings {
pub filter: Option<MempoolFilterSettings>,
pub size_limit: Option<usize>,
pub control_size_limit: Option<usize>,
pub blacklist_limit: Option<usize>,
}

Expand Down Expand Up @@ -427,6 +428,9 @@ impl From<MempoolSettings> 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),
Expand Down
5 changes: 4 additions & 1 deletion mempool/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
}
Expand Down
5 changes: 4 additions & 1 deletion mempool/src/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RwLock<Blockchain>>, config: MempoolConfig) -> Self {
Expand Down

0 comments on commit 20a0980

Please sign in to comment.