-
Notifications
You must be signed in to change notification settings - Fork 132
/
mempool.rs
69 lines (58 loc) · 1.6 KB
/
mempool.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use std::path::PathBuf;
use serde::{Deserialize, Serialize};
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize)]
pub struct PoolMaxEntries(usize);
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize)]
pub struct LogMaxEntries(usize);
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Mempool {
/// maximum number of entries in the mempool
#[serde(default)]
pub pool_max_entries: PoolMaxEntries,
/// maximum number of entries in the fragment logs
#[serde(default)]
pub log_max_entries: LogMaxEntries,
/// path to the persistent log of all incoming fragments
#[serde(default)]
pub persistent_log_path: Option<PathBuf>,
}
impl Default for PoolMaxEntries {
fn default() -> Self {
PoolMaxEntries(10_000)
}
}
impl Default for LogMaxEntries {
fn default() -> Self {
LogMaxEntries(100_000)
}
}
impl Default for Mempool {
fn default() -> Self {
Mempool {
pool_max_entries: PoolMaxEntries::default(),
log_max_entries: LogMaxEntries::default(),
persistent_log_path: None,
}
}
}
impl From<usize> for PoolMaxEntries {
fn from(s: usize) -> Self {
PoolMaxEntries(s)
}
}
impl From<PoolMaxEntries> for usize {
fn from(s: PoolMaxEntries) -> Self {
s.0
}
}
impl From<usize> for LogMaxEntries {
fn from(s: usize) -> Self {
LogMaxEntries(s)
}
}
impl From<LogMaxEntries> for usize {
fn from(s: LogMaxEntries) -> Self {
s.0
}
}