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:
parent
dd1f0a6dcc
commit
0683e0b40b
|
|
@ -1,11 +1,14 @@
|
||||||
//! Zebra mempool.
|
//! Zebra mempool.
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashSet,
|
collections::HashSet,
|
||||||
future::Future,
|
future::Future,
|
||||||
iter,
|
iter,
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
use futures::{future::FutureExt, stream::Stream};
|
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.
|
/// Mempool async management and query service.
|
||||||
///
|
///
|
||||||
/// The mempool is the set of all verified transactions that this node is aware
|
/// The mempool is the set of all verified transactions that this node is aware
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ use std::{net::SocketAddr, path::PathBuf};
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::components::mempool::Config as MempoolSection;
|
||||||
use zebra_consensus::Config as ConsensusSection;
|
use zebra_consensus::Config as ConsensusSection;
|
||||||
use zebra_network::Config as NetworkSection;
|
use zebra_network::Config as NetworkSection;
|
||||||
use zebra_state::Config as StateSection;
|
use zebra_state::Config as StateSection;
|
||||||
|
|
@ -37,6 +38,9 @@ pub struct ZebradConfig {
|
||||||
|
|
||||||
/// Sync configuration
|
/// Sync configuration
|
||||||
pub sync: SyncSection,
|
pub sync: SyncSection,
|
||||||
|
|
||||||
|
/// Mempool configuration
|
||||||
|
pub mempool: MempoolSection,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tracing configuration section.
|
/// Tracing configuration section.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue