dusk_node/mempool/
conf.rs1use std::fmt::Formatter;
8use std::time::Duration;
9
10use serde::{Deserialize, Serialize};
11
12pub const DEFAULT_EXPIRY_TIME: Duration = Duration::from_secs(3 * 60 * 60 * 24); pub const DEFAULT_IDLE_INTERVAL: Duration = Duration::from_secs(60 * 60); pub const DEFAULT_DOWNLOAD_REDUNDANCY: usize = 5;
16pub const DEFAULT_MAX_MOONLIGHT_FUTURE_NONCE_PER_ACCOUNT: usize = 64;
17
18#[derive(Serialize, Deserialize, Copy, Clone)]
19pub struct Params {
20 pub max_queue_size: usize,
22
23 pub max_mempool_txn_count: usize,
25
26 #[serde(default = "default_max_moonlight_future_nonce_per_account")]
29 pub max_moonlight_future_nonce_per_account: usize,
30
31 #[serde(with = "humantime_serde")]
33 pub idle_interval: Option<Duration>,
34
35 #[serde(with = "humantime_serde")]
37 pub mempool_expiry: Option<Duration>,
38
39 pub mempool_download_redundancy: Option<usize>,
41}
42
43impl Default for Params {
44 fn default() -> Self {
45 Self {
46 max_queue_size: 1000,
47 max_mempool_txn_count: 10_000,
48 max_moonlight_future_nonce_per_account:
49 DEFAULT_MAX_MOONLIGHT_FUTURE_NONCE_PER_ACCOUNT,
50 idle_interval: Some(DEFAULT_IDLE_INTERVAL),
51 mempool_expiry: Some(DEFAULT_EXPIRY_TIME),
52 mempool_download_redundancy: Some(DEFAULT_DOWNLOAD_REDUNDANCY),
53 }
54 }
55}
56
57const fn default_max_moonlight_future_nonce_per_account() -> usize {
58 DEFAULT_MAX_MOONLIGHT_FUTURE_NONCE_PER_ACCOUNT
59}
60
61impl std::fmt::Display for Params {
62 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
63 write!(
64 f,
65 "max_queue_size: {}, max_mempool_txn_count: {}, max_moonlight_future_nonce_per_account: {},
66 idle_interval: {:?}, mempool_expiry: {:?}, mempool_download_redundancy: {:?}",
67 self.max_queue_size,
68 self.max_mempool_txn_count,
69 self.max_moonlight_future_nonce_per_account,
70 self.idle_interval,
71 self.mempool_expiry,
72 self.mempool_download_redundancy
73 )
74 }
75}