diff --git a/rust-bins/duniter-dbex/src/cli.rs b/rust-bins/duniter-dbex/src/cli.rs index e98ee25e2c44f06f620797a52bd275be8e8d92bf..aa8aa5420be98fc258621c5030333fda7c6daa4f 100644 --- a/rust-bins/duniter-dbex/src/cli.rs +++ b/rust-bins/duniter-dbex/src/cli.rs @@ -28,7 +28,7 @@ pub struct Opt { pub home: Option<PathBuf>, /// database - #[structopt(default_value = "bc_v1", possible_values = &["bc_v1", "bc_v2", "gva_v1", "txs_mp_v2"])] + #[structopt(default_value = "bc_v1", possible_values = &["bc_v1", "bc_v2", "dunp_v1", "gva_v1", "txs_mp_v2"])] pub database: Database, #[structopt(subcommand)] @@ -39,6 +39,7 @@ pub struct Opt { pub enum Database { BcV1, BcV2, + DunpV1, GvaV1, TxsMpV2, } @@ -50,6 +51,7 @@ impl FromStr for Database { match s { "bc_v1" => Ok(Self::BcV1), "bc_v2" => Ok(Self::BcV2), + "dunp_v1" => Ok(Self::DunpV1), "gva_v1" => Ok(Self::GvaV1), "txs_mp_v2" => Ok(Self::TxsMpV2), _ => unreachable!(), diff --git a/rust-bins/duniter-dbex/src/main.rs b/rust-bins/duniter-dbex/src/main.rs index ddd314b8b07b9867231f7aaeb712101d83a031d4..7002d803e983b046c6d6052844412c8be4442a2a 100644 --- a/rust-bins/duniter-dbex/src/main.rs +++ b/rust-bins/duniter-dbex/src/main.rs @@ -31,13 +31,13 @@ use self::cli::{Database, Opt, OutputFormat, SubCommand}; use self::stringify_json_value::stringify_json_value; use anyhow::anyhow; use comfy_table::Table; -use duniter_dbs::databases::bc_v2::{BcV2Db, BcV2DbWritable}; use duniter_dbs::databases::{ bc_v1::{BcV1Db, BcV1DbWritable}, + bc_v2::{BcV2Db, BcV2DbWritable}, + dunp_v1::{DunpV1Db, DunpV1DbWritable}, gva_v1::{GvaV1Db, GvaV1DbWritable}, txs_mp_v2::{TxsMpV2Db, TxsMpV2DbWritable}, }; -use duniter_dbs::kv_typed::backend::sled; use duniter_dbs::kv_typed::prelude::*; use duniter_dbs::prelude::*; use duniter_dbs::regex::Regex; @@ -100,23 +100,34 @@ fn main() -> anyhow::Result<()> { open_db_start_time, ), Database::BcV2 => apply_subcommand( - BcV2Db::<Sled>::open( - sled::Config::default().path(data_path.as_path().join("bc_v2_sled")), - )?, + BcV2Db::<Sled>::open(Sled::gen_backend_conf( + BcV2Db::<Sled>::NAME, + Some(profile_path.as_path()), + ))?, + opt.cmd, + open_db_start_time, + ), + Database::DunpV1 => apply_subcommand( + DunpV1Db::<Sled>::open(Sled::gen_backend_conf( + DunpV1Db::<Sled>::NAME, + Some(profile_path.as_path()), + ))?, opt.cmd, open_db_start_time, ), Database::GvaV1 => apply_subcommand( - GvaV1Db::<Sled>::open( - sled::Config::default().path(data_path.as_path().join("gva_v1_sled")), - )?, + GvaV1Db::<Sled>::open(Sled::gen_backend_conf( + GvaV1Db::<Sled>::NAME, + Some(profile_path.as_path()), + ))?, opt.cmd, open_db_start_time, ), Database::TxsMpV2 => apply_subcommand( - TxsMpV2Db::<Sled>::open( - sled::Config::default().path(data_path.as_path().join("txs_mp_v2_sled")), - )?, + TxsMpV2Db::<Sled>::open(Sled::gen_backend_conf( + TxsMpV2Db::<Sled>::NAME, + Some(profile_path.as_path()), + ))?, opt.cmd, open_db_start_time, ), diff --git a/rust-libs/duniter-dbs/src/lib.rs b/rust-libs/duniter-dbs/src/lib.rs index a9e2d3dd487f8f620408dc23b15a7c8522987a36..ade5c98f01b25029c755c29234e72584b2f4ac1f 100644 --- a/rust-libs/duniter-dbs/src/lib.rs +++ b/rust-libs/duniter-dbs/src/lib.rs @@ -40,6 +40,7 @@ pub use kv_typed; // Prelude pub mod prelude { + pub use crate::open_dbs::BackendConf; pub use crate::DuniterDbs; #[cfg(feature = "explorer")] pub use kv_typed::explorer::{ diff --git a/rust-libs/duniter-dbs/src/open_dbs.rs b/rust-libs/duniter-dbs/src/open_dbs.rs index 014d5aaf6f3f541626677c4944ddfc2e9b4161ae..cc07815fa189743f6d7992b45f7f91ad5605f5b2 100644 --- a/rust-libs/duniter-dbs/src/open_dbs.rs +++ b/rust-libs/duniter-dbs/src/open_dbs.rs @@ -23,25 +23,27 @@ use crate::*; pub fn open_dbs<B: BackendConf>( home_path_opt: Option<&Path>, ) -> (crate::databases::bc_v2::BcV2Db<B>, DuniterDbs<B>) { - let bc_db = - crate::databases::bc_v2::BcV2Db::<B>::open(B::gen_backend_conf("bc_v2", home_path_opt)) - .expect("fail to open BcV2 DB"); + let bc_db = crate::databases::bc_v2::BcV2Db::<B>::open(B::gen_backend_conf( + crate::databases::bc_v2::BcV2Db::<B>::NAME, + home_path_opt, + )) + .expect("fail to open BcV2 DB"); let dbs = DuniterDbs { bc_db_ro: bc_db.get_ro_handler(), cm_db: crate::databases::cm_v1::CmV1Db::<Mem>::open(MemConf::default()) .expect("fail to open CmV1 DB"), dunp_db: crate::databases::dunp_v1::DunpV1Db::<B>::open(B::gen_backend_conf( - "dunp_v1", + crate::databases::dunp_v1::DunpV1Db::<B>::NAME, home_path_opt, )) .expect("fail to open Dunp DB"), gva_db: crate::databases::gva_v1::GvaV1Db::<B>::open(B::gen_backend_conf( - "gva_v1", + crate::databases::gva_v1::GvaV1Db::<B>::NAME, home_path_opt, )) .expect("fail to open Gva DB"), txs_mp_db: crate::databases::txs_mp_v2::TxsMpV2Db::<B>::open(B::gen_backend_conf( - "txs_mp_v2", + crate::databases::txs_mp_v2::TxsMpV2Db::<B>::NAME, home_path_opt, )) .expect("fail to open TxsMp DB"),