Skip to content

Commit

Permalink
use sqlite sub dir
Browse files Browse the repository at this point in the history
  • Loading branch information
imabdulbasit committed Dec 2, 2024
1 parent b627615 commit ef72571
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
1 change: 0 additions & 1 deletion process-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ processes:
- ESPRESSO_SEQUENCER_IDENTITY_LATITUDE=-25.2744
- ESPRESSO_SEQUENCER_IDENTITY_LONGITUDE=133.7751
- ESPRESSO_SEQUENCER_PUBLIC_API_URL=http://localhost:$ESPRESSO_SEQUENCER4_API_PORT/
- ESPRESSO_SEQUENCER_SQLITE_PATH=$ESPRESSO_BASE_STORAGE_PATH/seq4-sqlite.db
- ESPRESSO_SEQUENCER_IS_DA=true
depends_on:
orchestrator:
Expand Down
16 changes: 9 additions & 7 deletions sequencer/src/persistence/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use hotshot_types::{
use jf_vid::VidScheme;
use sqlx::Row;
use sqlx::{query, Executor};
use std::{collections::BTreeMap, path::PathBuf, sync::Arc, time::Duration};
use std::{collections::BTreeMap, path::PathBuf, str::FromStr, sync::Arc, time::Duration};

use crate::{catchup::SqlStateCatchup, SeqTypes, ViewNumber};

Expand Down Expand Up @@ -70,18 +70,20 @@ pub struct PostgresOptions {
#[derive(Parser, Clone, Derivative, Default, From, Into)]
#[derivative(Debug)]
pub struct SqliteOptions {
/// File path for the SQLite database.
///
/// By default, it is set to `./sqlite.db` in the current directory.
/// SQLite will create the database file if it does not exist.
/// Base directory for the SQLite database.
/// The SQLite file will be created in the `sqlite` subdirectory with filename as `database`.
#[clap(
long,
env = "ESPRESSO_SEQUENCER_SQLITE_PATH",
default_value = "./sqlite.db"
env = "ESPRESSO_SEQUENCER_STORAGE_PATH",
value_parser = build_sqlite_path
)]
pub(crate) path: PathBuf,
}

pub fn build_sqlite_path(path: &str) -> anyhow::Result<PathBuf> {
Ok(PathBuf::from_str(path)?.join("sqlite").join("database"))
}

/// Options for database-backed persistence, supporting both Postgres and SQLite.
#[derive(Parser, Clone, Derivative, Default, From, Into)]
#[derivative(Debug)]
Expand Down

0 comments on commit ef72571

Please sign in to comment.