Skip to content

Commit

Permalink
rename config field
Browse files Browse the repository at this point in the history
  • Loading branch information
scarmuega committed Jan 23, 2025
1 parent 228ef2b commit c4140e8
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 43 deletions.
4 changes: 2 additions & 2 deletions docs/pages/configuration/schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ The `storage` section controls how Dolos stores data in the local file system. T
| wal_cache | integer | 50 |
| ledger_cache | integer | 500 |
| max_wal_history | integer | 10000 |
| max_slots_before_prune | integer | 10000 |
| max_ledger_history | integer | 10000 |

- `path`: is the root directory where all data will be stored.
- `wal_cache`: the size (in Mb) of the memory cache for the wal db.
- `ledger_cache`: the size (in Mb) of the memory cache for the ledger db.
- `max_wal_history`: the max number of slots to keep in the WAL.
- `max_slots_before_prune`: the max number of slots to keep in the ledger store before pruning
- `max_ledger_history`: the max number of slots to keep in the ledger store before pruning. If not set, the ledger will prune past the immutable slot.

## `genesis` section

Expand Down
2 changes: 1 addition & 1 deletion src/bin/dolos/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ pub async fn run(config: super::Config, _args: &Args) -> miette::Result<()> {
let sync = dolos::sync::pipeline(
&config.sync,
&config.upstream,
&config.storage,
wal.clone(),
ledger.clone(),
byron,
shelley,
mempool.clone(),
&config.retries,
false,
config.storage.max_slots_before_prune,
)
.into_diagnostic()
.context("bootstrapping sync pipeline")?;
Expand Down
2 changes: 1 addition & 1 deletion src/bin/dolos/doctor/rebuild_ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub fn run(config: &crate::Config, _args: &Args, feedback: &Feedback) -> miette:
&mut light,
&byron,
&shelley,
config.storage.max_slots_before_prune,
config.storage.max_ledger_history,
)
.into_diagnostic()
.context("importing blocks to ledger store")?;
Expand Down
31 changes: 1 addition & 30 deletions src/bin/dolos/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,35 +63,6 @@ struct Cli {
config: Option<std::path::PathBuf>,
}

#[derive(Serialize, Deserialize)]
pub struct StorageConfig {
path: std::path::PathBuf,

/// Size (in Mb) of memory allocated for WAL caching
wal_cache: Option<usize>,

/// Size (in Mb) of memory allocated for ledger caching
ledger_cache: Option<usize>,

/// Maximum number of slots (not blocks) to keep in the WAL
max_wal_history: Option<u64>,

/// Maximum number of slots to keep in the ledger before pruning
max_slots_before_prune: Option<u64>,
}

impl Default for StorageConfig {
fn default() -> Self {
Self {
path: PathBuf::from("data"),
wal_cache: None,
ledger_cache: None,
max_wal_history: None,
max_slots_before_prune: None,
}
}
}

#[derive(Serialize, Deserialize)]
pub struct GenesisConfig {
byron_path: PathBuf,
Expand Down Expand Up @@ -154,7 +125,7 @@ impl Default for LoggingConfig {
#[derive(Serialize, Deserialize)]
pub struct Config {
pub upstream: dolos::model::UpstreamConfig,
pub storage: StorageConfig,
pub storage: dolos::model::StorageConfig,
pub genesis: GenesisConfig,
pub sync: dolos::sync::Config,
pub submit: dolos::model::SubmitConfig,
Expand Down
2 changes: 1 addition & 1 deletion src/bin/dolos/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ pub fn run(config: &super::Config, args: &Args) -> miette::Result<()> {
let sync = dolos::sync::pipeline(
&config.sync,
&config.upstream,
&config.storage,
wal,
ledger,
byron,
shelley,
mempool,
&config.retries,
args.quit_on_tip,
config.storage.max_slots_before_prune,
)
.into_diagnostic()
.context("bootstrapping sync pipeline")?;
Expand Down
29 changes: 29 additions & 0 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,32 @@ pub struct UpstreamConfig {
pub struct SubmitConfig {
pub prune_height: Option<u64>,
}

#[derive(Serialize, Deserialize)]
pub struct StorageConfig {
pub path: std::path::PathBuf,

/// Size (in Mb) of memory allocated for WAL caching
pub wal_cache: Option<usize>,

/// Size (in Mb) of memory allocated for ledger caching
pub ledger_cache: Option<usize>,

/// Maximum number of slots (not blocks) to keep in the WAL
pub max_wal_history: Option<u64>,

/// Maximum number of slots to keep in the ledger before pruning
pub max_ledger_history: Option<u64>,
}

impl Default for StorageConfig {
fn default() -> Self {
Self {
path: std::path::PathBuf::from("data"),
wal_cache: None,
ledger_cache: None,
max_wal_history: None,
max_ledger_history: None,
}
}
}
4 changes: 2 additions & 2 deletions src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ pub fn apply_block_batch<'a>(
store: &mut LedgerStore,
byron: &byron::GenesisFile,
shelley: &shelley::GenesisFile,
max_slots_before_prune: Option<u64>,
max_ledger_history: Option<u64>,
) -> Result<(), LedgerError> {
let mut deltas: Vec<LedgerDelta> = vec![];

Expand All @@ -239,7 +239,7 @@ pub fn apply_block_batch<'a>(
.map(|x| x.0)
.unwrap();

let to_finalize = max_slots_before_prune
let to_finalize = max_ledger_history
.map(|x| tip - x)
.unwrap_or(lastest_immutable_slot(tip, byron, shelley));

Expand Down
8 changes: 4 additions & 4 deletions src/sync/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct Stage {
shelley: shelley::GenesisFile,
mempool: crate::mempool::Mempool, // Add this line

max_slots_before_prune: Option<u64>,
max_ledger_history: Option<u64>,

pub upstream: UpstreamPort,

Expand All @@ -35,18 +35,18 @@ impl Stage {
mempool: crate::mempool::Mempool,
byron: byron::GenesisFile,
shelley: shelley::GenesisFile,
max_slots_before_prune: Option<u64>,
max_ledger_history: Option<u64>,
) -> Self {
Self {
wal,
ledger,
mempool,
byron,
shelley,
max_ledger_history,
upstream: Default::default(),
block_count: Default::default(),
wal_count: Default::default(),
max_slots_before_prune,
}
}

Expand Down Expand Up @@ -87,7 +87,7 @@ impl Stage {
&mut self.ledger,
&self.byron,
&self.shelley,
self.max_slots_before_prune,
self.max_ledger_history,
)
.or_panic()?;

Expand Down
4 changes: 2 additions & 2 deletions src/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ fn define_gasket_policy(config: &Option<gasket::retries::Policy>) -> gasket::run
pub fn pipeline(
config: &Config,
upstream: &UpstreamConfig,
storage: &StorageConfig,
wal: WalStore,
ledger: LedgerStore,
byron: byron::GenesisFile,
shelley: shelley::GenesisFile,
mempool: Mempool,
retries: &Option<gasket::retries::Policy>,
quit_on_tip: bool,
max_slots_before_prune: Option<u64>,
) -> Result<Vec<gasket::runtime::Tether>, Error> {
let mut pull = pull::Stage::new(
upstream.peer_address.clone(),
Expand All @@ -72,7 +72,7 @@ pub fn pipeline(
mempool.clone(),
byron,
shelley,
max_slots_before_prune,
storage.max_ledger_history,
);

let submit = submit::Stage::new(
Expand Down

0 comments on commit c4140e8

Please sign in to comment.