diff --git a/zebrad/src/components/mempool.rs b/zebrad/src/components/mempool.rs index b1340cde..10c72990 100644 --- a/zebrad/src/components/mempool.rs +++ b/zebrad/src/components/mempool.rs @@ -1,11 +1,14 @@ //! Zebra mempool. +use serde::{Deserialize, Serialize}; + use std::{ collections::HashSet, future::Future, iter, pin::Pin, task::{Context, Poll}, + time::Duration, }; use futures::{future::FutureExt, stream::Stream}; @@ -91,6 +94,30 @@ enum ActiveState { }, } +/// Mempool configuration section. +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct Config { + /// The transaction cost limit + pub tx_cost_limit: u32, + /// Max amount of minutes for transactions to be in recently evicted + pub eviction_memory_time: Duration, +} + +/// Consensus rules: +/// +/// - There MUST be a configuration option mempooltxcostlimit, which SHOULD default to 80000000. +/// - There MUST be a configuration option mempoolevictionmemoryminutes, which SHOULD default to 60. +/// +/// https://zips.z.cash/zip-0401#specification +impl Default for Config { + fn default() -> Self { + Self { + tx_cost_limit: 80_000_000, + eviction_memory_time: Duration::from_secs(60 * 60), + } + } +} + /// Mempool async management and query service. /// /// The mempool is the set of all verified transactions that this node is aware diff --git a/zebrad/src/config.rs b/zebrad/src/config.rs index 5c4b9f60..25a483f1 100644 --- a/zebrad/src/config.rs +++ b/zebrad/src/config.rs @@ -8,6 +8,7 @@ use std::{net::SocketAddr, path::PathBuf}; use serde::{Deserialize, Serialize}; +use crate::components::mempool::Config as MempoolSection; use zebra_consensus::Config as ConsensusSection; use zebra_network::Config as NetworkSection; use zebra_state::Config as StateSection; @@ -37,6 +38,9 @@ pub struct ZebradConfig { /// Sync configuration pub sync: SyncSection, + + /// Mempool configuration + pub mempool: MempoolSection, } /// Tracing configuration section.