Add a mempool config section (#2845)

* add mempool config section

* change to Duration

* fix typo in var name

* document consensus rules

* tweak var name
This commit is contained in:
Alfredo Garcia 2021-10-07 19:47:37 -03:00 committed by GitHub
parent dd1f0a6dcc
commit 0683e0b40b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View File

@ -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

View File

@ -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.