From e867b5cffa0cca7618f7daf4d6afb7e5f777cfd9 Mon Sep 17 00:00:00 2001
From: librelois <elois@ifee.fr>
Date: Sun, 2 Jun 2019 17:07:37 +0200
Subject: [PATCH] [ref] whole: #156 mv currency from conf to currency_params db

---
 Cargo.lock                                    |  19 ++-
 lib/core/conf/Cargo.toml                      |   1 +
 lib/core/conf/src/constants.rs                |   3 +
 lib/core/conf/src/lib.rs                      |  27 +--
 lib/core/core/Cargo.toml                      |   1 +
 lib/core/core/src/commands/dbex.rs            |   5 -
 lib/core/core/src/errors.rs                   |   4 +
 lib/core/core/src/lib.rs                      |  26 ++-
 lib/core/module/Cargo.toml                    |   1 +
 lib/core/module/src/lib.rs                    |   9 +-
 .../blockchain/blockchain-dal/src/lib.rs      |   4 -
 .../src/readers/currency_params.rs            |  45 +----
 lib/modules/blockchain/blockchain/src/dbex.rs |  49 +++---
 .../blockchain/blockchain/src/dubp/mod.rs     |   5 +-
 .../blockchain/src/dunp/receiver.rs           |   4 +-
 .../blockchain/src/fork/rollback.rs           |   2 +-
 lib/modules/blockchain/blockchain/src/lib.rs  |  28 +--
 .../src/sync/apply/blocks_worker.rs           |   3 +-
 .../blockchain/src/sync/apply/txs_worker.rs   |   3 +-
 .../blockchain/src/sync/apply/wot_worker.rs   |   3 +-
 .../src/sync/download/json_reader_worker.rs   |   2 +-
 .../blockchain/blockchain/src/sync/mod.rs     |  39 ++---
 lib/modules/skeleton/Cargo.toml               |   2 +
 lib/modules/skeleton/lib.rs                   |   2 +
 lib/modules/tui/Cargo.toml                    |   1 +
 lib/modules/tui/lib.rs                        |   2 +
 lib/modules/ws2p-v1-legacy/Cargo.toml         |   1 +
 lib/modules/ws2p-v1-legacy/src/lib.rs         |  23 +--
 .../ws2p-v1-legacy/src/parsers/blocks.rs      |   5 +-
 .../ws2p-v1-legacy/src/ws_connections/mod.rs  |   4 +-
 lib/modules/ws2p/ws2p-messages/Cargo.toml     |   1 +
 lib/modules/ws2p/ws2p-messages/lib.rs         |   3 +-
 lib/modules/ws2p/ws2p-messages/v2/mod.rs      |   2 +-
 lib/modules/ws2p/ws2p-protocol/Cargo.toml     |   1 +
 .../src/controller/meta_datas.rs              |   3 +-
 .../src/controller/on_message/connect_msg.rs  |   6 -
 lib/modules/ws2p/ws2p/Cargo.toml              |   1 +
 .../src/controllers/incoming_connections.rs   |   2 +-
 .../src/controllers/outgoing_connections.rs   |   2 +-
 lib/modules/ws2p/ws2p/src/generate_peer.rs    |   3 +-
 lib/modules/ws2p/ws2p/src/lib.rs              |   2 +
 .../ws2p/ws2p/src/services/outgoing.rs        |   2 +-
 .../ws2p/ws2p/tests/connection_negociation.rs |   2 +-
 .../documents-tests-tools/Cargo.toml          |   1 +
 .../documents-tests-tools/src/mocks/mod.rs    |   3 +-
 lib/tools/currency-params/Cargo.toml          |   5 +-
 lib/tools/currency-params/src/constants.rs    |   3 +
 .../currency-params/src/currencies_codes.rs   |  73 ++++++++
 lib/tools/currency-params/src/db.rs           | 101 +++++++++++
 .../src/genesis_block_params.rs               |  52 ++++++
 .../src/genesis_block_params/v10.rs           | 153 +++++++++++++++++
 lib/tools/currency-params/src/lib.rs          |  42 +++--
 lib/tools/documents/Cargo.toml                |   2 +-
 lib/tools/documents/src/currencies_codes.rs   |  23 ---
 lib/tools/documents/src/documents/block.rs    | 159 +-----------------
 lib/tools/documents/src/lib.rs                |  70 --------
 lib/tools/documents/src/parsers/blocks.rs     |   4 +-
 lib/tools/network-documents/Cargo.toml        |   1 +
 .../network-documents/src/network_head_v3.rs  |   3 +-
 .../network-documents/src/network_peer.rs     |   3 +-
 60 files changed, 599 insertions(+), 452 deletions(-)
 create mode 100644 lib/tools/currency-params/src/currencies_codes.rs
 create mode 100644 lib/tools/currency-params/src/db.rs
 create mode 100644 lib/tools/currency-params/src/genesis_block_params.rs
 create mode 100644 lib/tools/currency-params/src/genesis_block_params/v10.rs
 delete mode 100644 lib/tools/documents/src/currencies_codes.rs

diff --git a/Cargo.lock b/Cargo.lock
index e5746f0e..60cb17bf 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -293,8 +293,8 @@ dependencies = [
 name = "dubp-documents"
 version = "0.12.0"
 dependencies = [
- "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "dup-crypto 0.6.0",
+ "dup-currency-params 0.1.0",
  "durs-common-tools 0.1.0",
  "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "json-pest-parser 0.1.0",
@@ -315,6 +315,7 @@ dependencies = [
  "dubp-documents 0.12.0",
  "dup-crypto 0.6.0",
  "dup-crypto-tests-tools 0.1.0",
+ "dup-currency-params 0.1.0",
 ]
 
 [[package]]
@@ -345,7 +346,10 @@ dependencies = [
 name = "dup-currency-params"
 version = "0.1.0"
 dependencies = [
- "dubp-documents 0.12.0",
+ "bincode 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "durs-common-tools 0.1.0",
+ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.86 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -439,6 +443,7 @@ dependencies = [
  "dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "dubp-documents 0.12.0",
  "dup-crypto 0.6.0",
+ "dup-currency-params 0.1.0",
  "durs-common-tools 0.1.0",
  "durs-module 0.2.0-a",
  "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -456,6 +461,7 @@ version = "0.2.0-a"
 dependencies = [
  "dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "dup-crypto 0.6.0",
+ "dup-currency-params 0.1.0",
  "durs-blockchain 0.2.0-a",
  "durs-common-tools 0.1.0",
  "durs-conf 0.2.0-a",
@@ -496,6 +502,7 @@ version = "0.2.0-a"
 dependencies = [
  "dubp-documents 0.12.0",
  "dup-crypto 0.6.0",
+ "dup-currency-params 0.1.0",
  "durs-common-tools 0.1.0",
  "durs-network-documents 0.3.1",
  "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -530,6 +537,7 @@ dependencies = [
  "bincode 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "dubp-documents 0.12.0",
  "dup-crypto 0.6.0",
+ "dup-currency-params 0.1.0",
  "durs-common-tools 0.1.0",
  "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -545,7 +553,9 @@ dependencies = [
 name = "durs-skeleton"
 version = "0.1.0"
 dependencies = [
+ "dubp-documents 0.12.0",
  "dup-crypto 0.6.0",
+ "dup-currency-params 0.1.0",
  "durs-common-tools 0.1.0",
  "durs-conf 0.2.0-a",
  "durs-message 0.2.0-a",
@@ -565,6 +575,7 @@ version = "0.2.0-a"
 dependencies = [
  "dubp-documents 0.12.0",
  "dup-crypto 0.6.0",
+ "dup-currency-params 0.1.0",
  "durs-common-tools 0.1.0",
  "durs-conf 0.2.0-a",
  "durs-message 0.2.0-a",
@@ -600,6 +611,7 @@ dependencies = [
  "bincode 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "dubp-documents 0.12.0",
  "dup-crypto 0.6.0",
+ "dup-currency-params 0.1.0",
  "durs-common-tests-tools 0.1.0",
  "durs-common-tools 0.1.0",
  "durs-conf 0.2.0-a",
@@ -627,6 +639,7 @@ dependencies = [
  "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "dubp-documents 0.12.0",
  "dup-crypto 0.6.0",
+ "dup-currency-params 0.1.0",
  "durs-common-tools 0.1.0",
  "durs-network-documents 0.3.1",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -642,6 +655,7 @@ version = "0.2.0-a"
 dependencies = [
  "dubp-documents 0.12.0",
  "dup-crypto 0.6.0",
+ "dup-currency-params 0.1.0",
  "durs-common-tools 0.1.0",
  "durs-module 0.2.0-a",
  "durs-network-documents 0.3.1",
@@ -662,6 +676,7 @@ dependencies = [
  "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "dubp-documents 0.12.0",
  "dup-crypto 0.6.0",
+ "dup-currency-params 0.1.0",
  "durs-common-tools 0.1.0",
  "durs-conf 0.2.0-a",
  "durs-message 0.2.0-a",
diff --git a/lib/core/conf/Cargo.toml b/lib/core/conf/Cargo.toml
index 78a2d5da..cfd8f937 100644
--- a/lib/core/conf/Cargo.toml
+++ b/lib/core/conf/Cargo.toml
@@ -12,6 +12,7 @@ path = "src/lib.rs"
 [dependencies]
 dirs = "1.0.2"
 dup-crypto = { path = "../../tools/crypto" }
+dup-currency-params = { path = "../../tools/currency-params" }
 dubp-documents= { path = "../../tools/documents" }
 durs-module = { path = "../module" }
 durs-common-tools = { path = "../../tools/common-tools" }
diff --git a/lib/core/conf/src/constants.rs b/lib/core/conf/src/constants.rs
index 3535cb46..f4141441 100644
--- a/lib/core/conf/src/constants.rs
+++ b/lib/core/conf/src/constants.rs
@@ -29,3 +29,6 @@ pub static DEFAULT_CURRENCY: &'static str = "g1";
 
 /// Default value for `default_sync_module` conf field
 pub static DEFAULT_DEFAULT_SYNC_MODULE: &'static str = "ws2p";
+
+/// Modules datas folder
+pub static MODULES_DATAS_FOLDER: &'static str = "datas";
diff --git a/lib/core/conf/src/lib.rs b/lib/core/conf/src/lib.rs
index a82f2c95..a7e703f7 100644
--- a/lib/core/conf/src/lib.rs
+++ b/lib/core/conf/src/lib.rs
@@ -35,8 +35,9 @@ extern crate serde_derive;
 pub mod constants;
 pub mod keys;
 
-use dubp_documents::CurrencyName;
+use crate::constants::MODULES_DATAS_FOLDER;
 use dup_crypto::keys::*;
+use dup_currency_params::CurrencyName;
 use durs_common_tools::fatal_error;
 use durs_module::{
     DursConfTrait, DursGlobalConfTrait, ModuleName, RequiredKeys, RequiredKeysContent,
@@ -221,12 +222,6 @@ pub enum DuRsGlobalConf {
 }
 
 impl DursGlobalConfTrait for DuRsGlobalConf {
-    fn currency(&self) -> CurrencyName {
-        match *self {
-            DuRsGlobalConf::V1(ref conf_v1) => conf_v1.currency.clone(),
-            DuRsGlobalConf::V2(ref conf_v2) => conf_v2.currency.clone(),
-        }
-    }
     fn my_node_id(&self) -> u32 {
         match *self {
             DuRsGlobalConf::V1(ref conf_v1) => conf_v1.my_node_id,
@@ -449,11 +444,11 @@ pub fn get_user_datas_folder() -> &'static str {
     constants::USER_DATAS_FOLDER
 }
 
-/// Returns the path to the folder containing the currency datas of the running profile
+/// Returns the path to the folder containing the modules datas of the running profile
 #[inline]
-pub fn datas_path(profile_path: PathBuf, currency: &CurrencyName) -> PathBuf {
+pub fn get_datas_path(profile_path: PathBuf) -> PathBuf {
     let mut datas_path = profile_path;
-    datas_path.push(currency.to_string());
+    datas_path.push(MODULES_DATAS_FOLDER);
     if !datas_path.as_path().exists() {
         if let Err(io_error) = fs::create_dir(datas_path.as_path()) {
             if io_error.kind() != std::io::ErrorKind::AlreadyExists {
@@ -512,18 +507,12 @@ pub fn keypairs_filepath(profiles_path: &Option<PathBuf>, profile: &str) -> Path
 
 /// Load configuration.
 pub fn load_conf(
-    mut profile_path: PathBuf,
+    profile_path: PathBuf,
     keypairs_file_path: &Option<PathBuf>,
 ) -> Result<(DuRsConf, DuniterKeyPairs), DursConfFileError> {
     // Load conf
     let (conf, keypairs) = load_conf_at_path(profile_path.clone(), keypairs_file_path)?;
 
-    // Create currency dir
-    profile_path.push(conf.currency().to_string());
-    if !profile_path.as_path().exists() {
-        fs::create_dir(profile_path.as_path()).expect("Impossible to create currency dir !");
-    }
-
     // Return conf and keypairs
     Ok((conf, keypairs))
 }
@@ -715,8 +704,8 @@ pub fn write_conf_file<DC: DursConfTrait>(
 }
 
 /// Returns the path to the database containing the blockchain
-pub fn get_blockchain_db_path(profile_path: PathBuf, currency: &CurrencyName) -> PathBuf {
-    let mut db_path = datas_path(profile_path, currency);
+pub fn get_blockchain_db_path(profile_path: PathBuf) -> PathBuf {
+    let mut db_path = get_datas_path(profile_path);
     db_path.push("blockchain/");
     if !db_path.as_path().exists() {
         if let Err(io_error) = fs::create_dir(db_path.as_path()) {
diff --git a/lib/core/core/Cargo.toml b/lib/core/core/Cargo.toml
index 03ae5221..7d4a8b7b 100644
--- a/lib/core/core/Cargo.toml
+++ b/lib/core/core/Cargo.toml
@@ -15,6 +15,7 @@ durs-blockchain = { path = "../../modules/blockchain/blockchain" }
 durs-common-tools = { path = "../../tools/common-tools" }
 durs-conf = { path = "../conf" }
 dup-crypto = { path = "../../tools/crypto" }
+dup-currency-params = { path = "../../tools/currency-params" }
 durs-message =  { path = "../message" }
 durs-module = { path = "../module" }
 durs-network = { path = "../network" }
diff --git a/lib/core/core/src/commands/dbex.rs b/lib/core/core/src/commands/dbex.rs
index 521c62ca..c8636552 100644
--- a/lib/core/core/src/commands/dbex.rs
+++ b/lib/core/core/src/commands/dbex.rs
@@ -106,13 +106,11 @@ impl DursExecutableCoreCommand for DbExOpt {
         match self.subcommand {
             DbExSubCommand::DistanceOpt(distance_opts) => dbex(
                 profile_path,
-                &durs_core.soft_meta_datas.conf,
                 self.csv,
                 &DBExQuery::WotQuery(DBExWotQuery::AllDistances(distance_opts.reverse)),
             ),
             DbExSubCommand::MemberOpt(member_opts) => dbex(
                 profile_path,
-                &durs_core.soft_meta_datas.conf,
                 self.csv,
                 &DBExQuery::WotQuery(DBExWotQuery::MemberDatas(member_opts.uid)),
             ),
@@ -120,14 +118,12 @@ impl DursExecutableCoreCommand for DbExOpt {
                 if members_opts.expire {
                     dbex(
                         profile_path,
-                        &durs_core.soft_meta_datas.conf,
                         self.csv,
                         &DBExQuery::WotQuery(DBExWotQuery::ExpireMembers(members_opts.reverse)),
                     );
                 } else {
                     dbex(
                         profile_path,
-                        &durs_core.soft_meta_datas.conf,
                         self.csv,
                         &DBExQuery::WotQuery(DBExWotQuery::ListMembers(members_opts.reverse)),
                     );
@@ -135,7 +131,6 @@ impl DursExecutableCoreCommand for DbExOpt {
             }
             DbExSubCommand::BalanceOpt(balance_opts) => dbex(
                 profile_path,
-                &durs_core.soft_meta_datas.conf,
                 self.csv,
                 &DBExQuery::TxQuery(DBExTxQuery::Balance(balance_opts.address)),
             ),
diff --git a/lib/core/core/src/errors.rs b/lib/core/core/src/errors.rs
index 0aac0cdf..6a7f2415 100644
--- a/lib/core/core/src/errors.rs
+++ b/lib/core/core/src/errors.rs
@@ -16,6 +16,7 @@
 //! Manage Durs core errors.
 
 use crate::logger::InitLoggerError;
+use dup_currency_params::db::CurrencyParamsDbError;
 use durs_module::{ModuleStaticName, PlugModuleError};
 use failure::Fail;
 
@@ -25,6 +26,9 @@ pub enum DursCoreError {
     /// Error with configuration file
     #[fail(display = "Error with configuration file: {}", _0)]
     ConfFileError(durs_conf::DursConfFileError),
+    /// Fail to read currency params DB
+    #[fail(display = "Fail to read currency params DB: {}", _0)]
+    FailReadCurrencyParamsDb(CurrencyParamsDbError),
     /// Fail to remove configuration file
     #[fail(display = "Fail to remove configuration file: {}", _0)]
     FailRemoveConfFile(std::io::Error),
diff --git a/lib/core/core/src/lib.rs b/lib/core/core/src/lib.rs
index 25d3887d..af51acb6 100644
--- a/lib/core/core/src/lib.rs
+++ b/lib/core/core/src/lib.rs
@@ -42,6 +42,7 @@ mod router;
 use crate::commands::*;
 use crate::constants::DEFAULT_USER_PROFILE;
 use crate::errors::DursCoreError;
+use dup_currency_params::CurrencyName;
 use durs_blockchain::{BlockchainModule, DBExQuery};
 use durs_common_tools::fatal_error;
 pub use durs_conf::{
@@ -73,6 +74,8 @@ macro_rules! durs_plug {
 
 /// Durs Core Datas
 pub struct DursCore<DC: DursConfTrait> {
+    /// Currency name
+    pub currency_name: Option<CurrencyName>,
     /// Durs core options
     pub options: DursCoreOptions,
     /// Does the entered command require to launch server ?
@@ -123,6 +126,7 @@ impl DursCore<DuRsConf> {
             .cloned();
 
         let ((module_conf, module_user_conf), required_keys) = get_module_conf_and_keys::<M>(
+            durs_core.currency_name.as_ref(),
             &durs_core.soft_meta_datas.conf.get_global_conf(),
             module_conf_json,
             durs_core.keypairs,
@@ -249,8 +253,15 @@ impl DursCore<DuRsConf> {
                 .map_err(DursCoreError::ConfFileError)?;
         info!("Success to load global conf.");
 
+        // Get currency name
+        let currency_name = dup_currency_params::db::get_currency_name(durs_conf::get_datas_path(
+            profile_path.clone(),
+        ))
+        .map_err(DursCoreError::FailReadCurrencyParamsDb)?;
+
         // Instanciate durs core
         Ok(DursCore {
+            currency_name,
             keypairs,
             options: durs_core_opts,
             modules_names: Vec::new(),
@@ -313,7 +324,6 @@ impl DursCore<DuRsConf> {
         let mut blockchain_module = BlockchainModule::load_blockchain_conf(
             router_sender.clone(),
             profile_path,
-            &self.soft_meta_datas.conf,
             RequiredKeysContent::MemberKeyPair(None),
         );
         info!("Success to load Blockchain module.");
@@ -392,6 +402,7 @@ impl DursCore<DuRsConf> {
 
                     // Load module conf and keys
                     let ((module_conf, _), required_keys) = get_module_conf_and_keys::<NM>(
+                        self.currency_name.as_ref(),
                         &soft_meta_datas.conf.get_global_conf(),
                         module_conf_json,
                         keypairs,
@@ -476,6 +487,7 @@ impl DursCore<DuRsConf> {
                 let keypairs = self.keypairs;
                 // Load module conf and keys
                 let ((module_conf, _), required_keys) = get_module_conf_and_keys::<M>(
+                    self.currency_name.as_ref(),
                     &soft_meta_datas.conf.get_global_conf(),
                     module_conf_json,
                     keypairs,
@@ -543,27 +555,29 @@ pub type ModuleConfsAndKeys<M> = (
 
 /// Get module conf and keys
 pub fn get_module_conf_and_keys<M: DursModule<DuRsConf, DursMsg>>(
+    currency_name: Option<&CurrencyName>,
     global_conf: &<DuRsConf as DursConfTrait>::GlobalConf,
     module_conf_json: Option<serde_json::Value>,
     keypairs: DuniterKeyPairs,
 ) -> Result<ModuleConfsAndKeys<M>, ModuleConfError> {
     Ok((
-        get_module_conf::<M>(global_conf, module_conf_json)?,
+        get_module_conf::<M>(currency_name, global_conf, module_conf_json)?,
         DuniterKeyPairs::get_required_keys_content(M::ask_required_keys(), keypairs),
     ))
 }
 
 /// get module conf
 pub fn get_module_conf<M: DursModule<DuRsConf, DursMsg>>(
+    currency_name: Option<&CurrencyName>,
     global_conf: &<DuRsConf as DursConfTrait>::GlobalConf,
     module_conf_json: Option<serde_json::Value>,
 ) -> Result<(M::ModuleConf, Option<M::ModuleUserConf>), ModuleConfError> {
     if let Some(module_conf_json) = module_conf_json {
         let module_user_conf: Option<M::ModuleUserConf> =
             serde_json::from_str(module_conf_json.to_string().as_str())?;
-        M::generate_module_conf(global_conf, module_user_conf)
+        M::generate_module_conf(currency_name, global_conf, module_user_conf)
     } else {
-        M::generate_module_conf(global_conf, None)
+        M::generate_module_conf(currency_name, global_conf, None)
     }
 }
 
@@ -574,9 +588,9 @@ pub fn sync_ts<DC: DursConfTrait>(profile_path: PathBuf, conf: &DC, sync_opts: S
 }
 
 /// Launch databases explorer
-pub fn dbex<DC: DursConfTrait>(profile_path: PathBuf, conf: &DC, csv: bool, query: &DBExQuery) {
+pub fn dbex(profile_path: PathBuf, csv: bool, query: &DBExQuery) {
     // Launch databases explorer
-    BlockchainModule::dbex(profile_path, conf, csv, query);
+    BlockchainModule::dbex(profile_path, csv, query);
 }
 
 #[inline]
diff --git a/lib/core/module/Cargo.toml b/lib/core/module/Cargo.toml
index efee9ebf..4f63782f 100644
--- a/lib/core/module/Cargo.toml
+++ b/lib/core/module/Cargo.toml
@@ -11,6 +11,7 @@ path = "src/lib.rs"
 
 [dependencies]
 dup-crypto = { path = "../../tools/crypto" }
+dup-currency-params = { path = "../../tools/currency-params" }
 dubp-documents = { path = "../../tools/documents" }
 durs-common-tools = { path = "../../tools/common-tools" }
 durs-network-documents = { path = "../../tools/network-documents" }
diff --git a/lib/core/module/src/lib.rs b/lib/core/module/src/lib.rs
index 6e8f96ed..74b1cf0f 100644
--- a/lib/core/module/src/lib.rs
+++ b/lib/core/module/src/lib.rs
@@ -31,8 +31,8 @@
 #[macro_use]
 extern crate serde_derive;
 
-use dubp_documents::CurrencyName;
 use dup_crypto::keys::{KeyPair, KeyPairEnum};
+use dup_currency_params::CurrencyName;
 use durs_common_tools::fatal_error;
 use durs_common_tools::traits::merge::Merge;
 use durs_network_documents::network_endpoint::{ApiPart, EndpointEnum};
@@ -107,8 +107,6 @@ impl ToString for ModuleReqFullId {
 pub trait DursGlobalConfTrait:
     Clone + Debug + PartialEq + Serialize + DeserializeOwned + Send + ToOwned
 {
-    /// Get currency
-    fn currency(&self) -> CurrencyName;
     /// Get node id
     fn my_node_id(&self) -> u32;
     /// Get default sync module
@@ -122,10 +120,6 @@ pub trait DursConfTrait:
     /// Durs configuration without modules configuration
     type GlobalConf: DursGlobalConfTrait;
 
-    /// Get currency
-    fn currency(&self) -> CurrencyName {
-        self.get_global_conf().currency()
-    }
     /// Disable a module
     fn disable(&mut self, module: ModuleName);
     /// Get disabled modules
@@ -424,6 +418,7 @@ pub trait DursModule<DC: DursConfTrait, M: ModuleMessage> {
     fn ask_required_keys() -> RequiredKeys;
     /// Generate module configuration
     fn generate_module_conf(
+        currency_name: Option<&CurrencyName>,
         global_conf: &DC::GlobalConf,
         module_user_conf: Option<Self::ModuleUserConf>,
     ) -> Result<(Self::ModuleConf, Option<Self::ModuleUserConf>), ModuleConfError>;
diff --git a/lib/modules/blockchain/blockchain-dal/src/lib.rs b/lib/modules/blockchain/blockchain-dal/src/lib.rs
index 44b7e540..b9c8fa76 100644
--- a/lib/modules/blockchain/blockchain-dal/src/lib.rs
+++ b/lib/modules/blockchain/blockchain-dal/src/lib.rs
@@ -51,9 +51,7 @@ pub mod tools;
 /// Contains all write databases functions
 pub mod writers;
 
-use dubp_documents::documents::block::BlockV10Parameters;
 use dubp_documents::documents::transaction::*;
-use dubp_documents::CurrencyName;
 use dubp_documents::{BlockHash, BlockNumber, Blockstamp, PreviousBlockstamp};
 use dup_crypto::hashs::Hash;
 use dup_crypto::keys::*;
@@ -77,8 +75,6 @@ use crate::entities::identity::DALIdentity;
 use crate::entities::sources::{SourceAmount, UTXOContentV10, UTXOIndexV10};
 use crate::writers::transaction::DALTxV10;
 
-/// Currency parameters (Protocol V10)
-pub type CurrencyParamsV10Datas = Option<(CurrencyName, BlockV10Parameters)>;
 /// All blocks of local blockchain indexed by block number
 pub type LocalBlockchainV10Datas = FnvHashMap<BlockNumber, DALBlock>;
 /// Forks tree meta datas (block number and hash only)
diff --git a/lib/modules/blockchain/blockchain-dal/src/readers/currency_params.rs b/lib/modules/blockchain/blockchain-dal/src/readers/currency_params.rs
index a23c2ac5..44dec3e6 100644
--- a/lib/modules/blockchain/blockchain-dal/src/readers/currency_params.rs
+++ b/lib/modules/blockchain/blockchain-dal/src/readers/currency_params.rs
@@ -13,25 +13,13 @@
 // You should have received a copy of the GNU Affero General Public License
 // along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-use crate::constants::CURRENCY_PARAMS_DB_NAME;
 use crate::*;
 use dubp_documents::documents::block::BlockDocument;
+use dup_currency_params::db::write_currency_params;
+use dup_currency_params::genesis_block_params::GenesisBlockParams;
 use dup_currency_params::CurrencyParameters;
-use durs_conf::constants::DEFAULT_CURRENCY;
 use unwrap::unwrap;
 
-/// Get currency parameters
-pub fn get_currency_params(db_path: &PathBuf) -> Result<Option<CurrencyParameters>, DALError> {
-    let currency_params_db =
-        open_file_db::<CurrencyParamsV10Datas>(db_path, CURRENCY_PARAMS_DB_NAME)
-            .expect("Fail to open params db");
-    Ok(currency_params_db.read(|db| {
-        db.as_ref().map(|(currency_name, block_genesis_params)| {
-            CurrencyParameters::from((currency_name.clone(), *block_genesis_params))
-        })
-    })?)
-}
-
 /// Get and write currency params
 pub fn get_and_write_currency_params(
     db_path: &PathBuf,
@@ -41,28 +29,13 @@ pub fn get_and_write_currency_params(
         fatal_error!("The genesis block must have number equal to zero !");
     } else if genesis_block.parameters.is_none() {
         fatal_error!("The genesis block must have parameters !");
+    } else if let Err(e) = write_currency_params(
+        db_path.clone(),
+        genesis_block.currency.clone(),
+        GenesisBlockParams::V10(unwrap!(genesis_block.parameters)),
+    ) {
+        fatal_error!("Fail to write currency parameters: {}", e);
     } else {
-        let currency_params_db = BinDB::File(
-            open_file_db::<CurrencyParamsV10Datas>(&db_path, CURRENCY_PARAMS_DB_NAME)
-                .expect("Fail to open params db"),
-        );
-        if genesis_block.currency.0 != DEFAULT_CURRENCY {
-            let mut default_currency_path = db_path.clone();
-            default_currency_path.push(DEFAULT_CURRENCY);
-            let _ = std::fs::remove_file(default_currency_path.as_path());
-        }
-        currency_params_db
-            .write(|db| {
-                db.replace((
-                    genesis_block.currency.clone(),
-                    unwrap!(genesis_block.parameters),
-                ));
-            })
-            .expect("fail to write in params DB");
-        currency_params_db.save().expect("Fail to save params db");
-        CurrencyParameters::from((
-            genesis_block.currency.clone(),
-            unwrap!(genesis_block.parameters),
-        ))
+        CurrencyParameters::from((&genesis_block.currency, unwrap!(genesis_block.parameters)))
     }
 }
diff --git a/lib/modules/blockchain/blockchain/src/dbex.rs b/lib/modules/blockchain/blockchain/src/dbex.rs
index a41a6c03..e74145a6 100644
--- a/lib/modules/blockchain/blockchain/src/dbex.rs
+++ b/lib/modules/blockchain/blockchain/src/dbex.rs
@@ -16,12 +16,14 @@
 use crate::*;
 use dubp_documents::documents::transaction::*;
 use dup_crypto::keys::*;
-use durs_blockchain_dal::constants::CURRENCY_PARAMS_DB_NAME;
-use durs_module::DursConfTrait;
 use durs_wot::data::rusty::RustyWebOfTrust;
 use durs_wot::data::WebOfTrust;
 use durs_wot::operations::distance::{DistanceCalculator, WotDistance, WotDistanceParameters};
 use std::time::*;
+use unwrap::unwrap;
+
+pub static EMPTY_BLOCKCHAIN: &'static str =
+    "No blockchain, please sync your node to get a blockchain.";
 
 #[derive(Debug, Clone)]
 /// Query for wot databases explorer
@@ -52,21 +54,16 @@ pub enum DBExQuery {
     TxQuery(DBExTxQuery),
 }
 
-pub fn dbex<DC: DursConfTrait>(profile_path: PathBuf, conf: &DC, csv: bool, query: &DBExQuery) {
+pub fn dbex(profile_path: PathBuf, csv: bool, query: &DBExQuery) {
     match *query {
-        DBExQuery::WotQuery(ref wot_query) => dbex_wot(profile_path, conf, csv, wot_query),
-        DBExQuery::TxQuery(ref tx_query) => dbex_tx(profile_path, conf, csv, tx_query),
+        DBExQuery::WotQuery(ref wot_query) => dbex_wot(profile_path, csv, wot_query),
+        DBExQuery::TxQuery(ref tx_query) => dbex_tx(profile_path, csv, tx_query),
     }
 }
 
-pub fn dbex_tx<DC: DursConfTrait>(
-    profile_path: PathBuf,
-    conf: &DC,
-    _csv: bool,
-    query: &DBExTxQuery,
-) {
+pub fn dbex_tx(profile_path: PathBuf, _csv: bool, query: &DBExTxQuery) {
     // Get db path
-    let db_path = durs_conf::get_blockchain_db_path(profile_path, &conf.currency());
+    let db_path = durs_conf::get_blockchain_db_path(profile_path);
 
     // Open databases
     let load_dbs_begin = SystemTime::now();
@@ -123,20 +120,12 @@ pub fn dbex_tx<DC: DursConfTrait>(
     );
 }
 
-pub fn dbex_wot<DC: DursConfTrait>(
-    profile_path: PathBuf,
-    conf: &DC,
-    csv: bool,
-    query: &DBExWotQuery,
-) {
+pub fn dbex_wot(profile_path: PathBuf, csv: bool, query: &DBExWotQuery) {
     // Get db path
-    let db_path = durs_conf::get_blockchain_db_path(profile_path, &conf.currency());
+    let db_path = durs_conf::get_blockchain_db_path(profile_path.clone());
 
     // Open databases
     let load_dbs_begin = SystemTime::now();
-    let currency_params_db =
-        open_file_db::<CurrencyParamsV10Datas>(&db_path, CURRENCY_PARAMS_DB_NAME)
-            .expect("Fail to open params db");
     let wot_databases = WotsV10DBs::open(Some(&db_path));
     let load_dbs_duration = SystemTime::now()
         .duration_since(load_dbs_begin)
@@ -148,14 +137,14 @@ pub fn dbex_wot<DC: DursConfTrait>(
     );
 
     // Get currency parameters
-    let currency_params = currency_params_db
-        .read(|db| {
-            db.as_ref().map(|(currency_name, block_genesis_params)| {
-                CurrencyParameters::from((currency_name.clone(), *block_genesis_params))
-            })
-        })
-        .expect("Fail to parse currency params !")
-        .unwrap_or_default();
+    let currency_params_db_datas =
+        dup_currency_params::db::get_currency_params(durs_conf::get_datas_path(profile_path))
+            .expect("Fail to parse currency params !");
+    if currency_params_db_datas.is_none() {
+        println!("{}", EMPTY_BLOCKCHAIN);
+        return;
+    }
+    let currency_params = unwrap!(currency_params_db_datas).1;
 
     // get wot_index
     let wot_index =
diff --git a/lib/modules/blockchain/blockchain/src/dubp/mod.rs b/lib/modules/blockchain/blockchain/src/dubp/mod.rs
index aca84e0f..58928ef8 100644
--- a/lib/modules/blockchain/blockchain/src/dubp/mod.rs
+++ b/lib/modules/blockchain/blockchain/src/dubp/mod.rs
@@ -105,11 +105,12 @@ pub fn check_and_apply_block(
         // If we're in block genesis, get the currency parameters
         if block_doc.number == BlockNumber(0) {
             // Open currency_params_db
-            let dbs_path = durs_conf::get_blockchain_db_path(bc.profile_path.clone(), &bc.currency);
+            let datas_path = durs_conf::get_datas_path(bc.profile_path.clone());
             // Get and write currency params
             bc.currency_params = Some(
                 durs_blockchain_dal::readers::currency_params::get_and_write_currency_params(
-                    &dbs_path, &block_doc,
+                    &datas_path,
+                    &block_doc,
                 ),
             );
         }
diff --git a/lib/modules/blockchain/blockchain/src/dunp/receiver.rs b/lib/modules/blockchain/blockchain/src/dunp/receiver.rs
index f6c141fe..eb5db11d 100644
--- a/lib/modules/blockchain/blockchain/src/dunp/receiver.rs
+++ b/lib/modules/blockchain/blockchain/src/dunp/receiver.rs
@@ -91,7 +91,7 @@ pub fn receive_blocks(bc: &mut BlockchainModule, blocks: Vec<BlockDocument>) {
                 CheckAndApplyBlockReturn::OrphanBlock => {
                     if first_orphan {
                         first_orphan = false;
-                        info!("new orphan block(#{})", blockstamp); // TODO debug
+                        debug!("new orphan block(#{})", blockstamp);
                         crate::requests::sent::request_orphan_previous(bc, blockstamp);
                     }
                 }
@@ -113,7 +113,7 @@ pub fn receive_blocks(bc: &mut BlockchainModule, blocks: Vec<BlockDocument>) {
                     debug!("AlreadyHaveBlock(#{})", blockstamp.id);
                 }
                 BlockError::BlockOrOutForkWindow => {
-                    info!("BlockOrOutForkWindow(#{})", blockstamp); // TODO debug
+                    debug!("BlockOrOutForkWindow(#{})", blockstamp);
                 }
             },
         }
diff --git a/lib/modules/blockchain/blockchain/src/fork/rollback.rs b/lib/modules/blockchain/blockchain/src/fork/rollback.rs
index 8d4eab35..fa060ea3 100644
--- a/lib/modules/blockchain/blockchain/src/fork/rollback.rs
+++ b/lib/modules/blockchain/blockchain/src/fork/rollback.rs
@@ -151,7 +151,7 @@ pub fn apply_rollback(bc: &mut BlockchainModule, new_bc_branch: Vec<Blockstamp>)
         }
     } else {
         // reload dbs
-        let dbs_path = durs_conf::get_blockchain_db_path(bc.profile_path.clone(), &bc.currency);
+        let dbs_path = durs_conf::get_blockchain_db_path(bc.profile_path.clone());
         bc.blocks_databases = BlocksV10DBs::open(Some(&dbs_path));
         bc.forks_dbs = ForksDBs::open(Some(&dbs_path));
         bc.wot_databases = WotsV10DBs::open(Some(&dbs_path));
diff --git a/lib/modules/blockchain/blockchain/src/lib.rs b/lib/modules/blockchain/blockchain/src/lib.rs
index 89a9616e..2645a428 100644
--- a/lib/modules/blockchain/blockchain/src/lib.rs
+++ b/lib/modules/blockchain/blockchain/src/lib.rs
@@ -57,7 +57,7 @@ use crate::fork::*;
 use dubp_documents::documents::block::BlockDocument;
 use dubp_documents::*;
 use dup_crypto::keys::*;
-use dup_currency_params::CurrencyParameters;
+use dup_currency_params::{CurrencyName, CurrencyParameters};
 use durs_blockchain_dal::*;
 use durs_common_tools::fatal_error;
 use durs_message::events::*;
@@ -92,7 +92,7 @@ pub struct BlockchainModule {
     ///Path to the user datas profile
     pub profile_path: PathBuf,
     /// Currency
-    pub currency: CurrencyName,
+    pub currency: Option<CurrencyName>,
     /// Blocks Databases
     pub blocks_databases: BlocksV10DBs,
     /// Forks Databases
@@ -186,14 +186,13 @@ impl BlockchainModule {
         ModuleStaticName(MODULE_NAME)
     }
     /// Loading blockchain configuration
-    pub fn load_blockchain_conf<DC: DursConfTrait>(
+    pub fn load_blockchain_conf(
         router_sender: mpsc::Sender<RouterThreadMessage<DursMsg>>,
         profile_path: PathBuf,
-        conf: &DC,
         _keys: RequiredKeysContent,
     ) -> BlockchainModule {
         // Get db path
-        let dbs_path = durs_conf::get_blockchain_db_path(profile_path.clone(), &conf.currency());
+        let dbs_path = durs_conf::get_blockchain_db_path(profile_path.clone());
 
         // Open databases
         let blocks_databases = BlocksV10DBs::open(Some(&dbs_path));
@@ -208,9 +207,16 @@ impl BlockchainModule {
                 .unwrap_or_default();
 
         // Get currency parameters
-        let currency_params =
-            durs_blockchain_dal::readers::currency_params::get_currency_params(&dbs_path)
-                .expect("Fatal error : fail to read Blockchain DB !");
+        let (currency_name, currency_params) = if let Some((currency_name, currency_params)) =
+            dup_currency_params::db::get_currency_params(durs_conf::get_datas_path(
+                profile_path.clone(),
+            ))
+            .expect("Fatal error : fail to read Blockchain DB !")
+        {
+            (Some(currency_name), Some(currency_params))
+        } else {
+            (None, None)
+        };
 
         // Get wot index
         let wot_index: HashMap<PubKey, NodeId> =
@@ -221,7 +227,7 @@ impl BlockchainModule {
         BlockchainModule {
             router_sender,
             profile_path,
-            currency: conf.currency(),
+            currency: currency_name,
             currency_params,
             current_blockstamp,
             consensus: Blockstamp::default(),
@@ -237,8 +243,8 @@ impl BlockchainModule {
         }
     }
     /// Databases explorer
-    pub fn dbex<DC: DursConfTrait>(profile_path: PathBuf, conf: &DC, csv: bool, req: &DBExQuery) {
-        dbex::dbex(profile_path, conf, csv, req);
+    pub fn dbex(profile_path: PathBuf, csv: bool, req: &DBExQuery) {
+        dbex::dbex(profile_path, csv, req);
     }
     /// Synchronize blockchain from local duniter json files
     pub fn sync_ts<DC: DursConfTrait>(profile_path: PathBuf, conf: &DC, sync_opts: SyncOpt) {
diff --git a/lib/modules/blockchain/blockchain/src/sync/apply/blocks_worker.rs b/lib/modules/blockchain/blockchain/src/sync/apply/blocks_worker.rs
index 9dbba076..9dc97931 100644
--- a/lib/modules/blockchain/blockchain/src/sync/apply/blocks_worker.rs
+++ b/lib/modules/blockchain/blockchain/src/sync/apply/blocks_worker.rs
@@ -23,7 +23,6 @@ pub fn execute(
     recv: mpsc::Receiver<SyncJobsMess>,
     blocks_dbs: BlocksV10DBs,
     forks_db: ForksDBs,
-    fork_window_size: usize,
     target_blockstamp: Blockstamp,
     mut apply_pb: ProgressBar<std::io::Stdout>,
 ) {
@@ -42,7 +41,7 @@ pub fn execute(
             req.apply(
                 &blocks_dbs.blockchain_db,
                 &forks_db,
-                fork_window_size,
+                200, // TODO replace by fork_window_size
                 Some(target_blockstamp),
             )
             .expect("Fatal error : Fail to apply DBWriteRequest !");
diff --git a/lib/modules/blockchain/blockchain/src/sync/apply/txs_worker.rs b/lib/modules/blockchain/blockchain/src/sync/apply/txs_worker.rs
index de0c7aaa..37e73bd4 100644
--- a/lib/modules/blockchain/blockchain/src/sync/apply/txs_worker.rs
+++ b/lib/modules/blockchain/blockchain/src/sync/apply/txs_worker.rs
@@ -19,7 +19,6 @@ use std::sync::mpsc;
 pub fn execute(
     pool: &ThreadPool,
     profile_path: PathBuf,
-    currency: CurrencyName,
     sender_sync_thread: mpsc::Sender<MessForSyncThread>,
     recv: mpsc::Receiver<SyncJobsMess>,
 ) {
@@ -27,7 +26,7 @@ pub fn execute(
     pool.execute(move || {
         let tx_job_begin = SystemTime::now();
         // Open databases
-        let db_path = durs_conf::get_blockchain_db_path(profile_path, &currency);
+        let db_path = durs_conf::get_blockchain_db_path(profile_path);
         let databases = CurrencyV10DBs::open(Some(&db_path));
 
         // Listen db requets
diff --git a/lib/modules/blockchain/blockchain/src/sync/apply/wot_worker.rs b/lib/modules/blockchain/blockchain/src/sync/apply/wot_worker.rs
index b80db590..5b9a3bab 100644
--- a/lib/modules/blockchain/blockchain/src/sync/apply/wot_worker.rs
+++ b/lib/modules/blockchain/blockchain/src/sync/apply/wot_worker.rs
@@ -20,7 +20,6 @@ use std::sync::mpsc;
 pub fn execute(
     pool: &ThreadPool,
     profile_path: PathBuf,
-    currency: CurrencyName,
     sender_sync_thread: mpsc::Sender<MessForSyncThread>,
     recv: mpsc::Receiver<SyncJobsMess>,
 ) {
@@ -28,7 +27,7 @@ pub fn execute(
     pool.execute(move || {
         let wot_job_begin = SystemTime::now();
         // Open databases
-        let db_path = durs_conf::get_blockchain_db_path(profile_path, &currency);
+        let db_path = durs_conf::get_blockchain_db_path(profile_path);
         let databases = WotsV10DBs::open(Some(&db_path));
 
         // Listen db requets
diff --git a/lib/modules/blockchain/blockchain/src/sync/download/json_reader_worker.rs b/lib/modules/blockchain/blockchain/src/sync/download/json_reader_worker.rs
index f29101a7..6e2dac28 100644
--- a/lib/modules/blockchain/blockchain/src/sync/download/json_reader_worker.rs
+++ b/lib/modules/blockchain/blockchain/src/sync/download/json_reader_worker.rs
@@ -94,7 +94,7 @@ pub fn json_reader_worker(
 
         // Get current local blockstamp
         debug!("Get local current blockstamp...");
-        let db_path = durs_conf::get_blockchain_db_path(profile_path, &last_block.currency);
+        let db_path = durs_conf::get_blockchain_db_path(profile_path);
         let blocks_databases = BlocksV10DBs::open(Some(&db_path));
         let current_blockstamp: Blockstamp =
             durs_blockchain_dal::readers::block::get_current_blockstamp(&blocks_databases)
diff --git a/lib/modules/blockchain/blockchain/src/sync/mod.rs b/lib/modules/blockchain/blockchain/src/sync/mod.rs
index 03bd0874..131dcbf6 100644
--- a/lib/modules/blockchain/blockchain/src/sync/mod.rs
+++ b/lib/modules/blockchain/blockchain/src/sync/mod.rs
@@ -20,7 +20,7 @@ use crate::dubp::apply::apply_valid_block;
 use crate::*;
 use dubp_documents::{BlockHash, BlockNumber};
 use dup_crypto::keys::*;
-use dup_currency_params::CurrencyParameters;
+use dup_currency_params::{CurrencyName, CurrencyParameters};
 use durs_blockchain_dal::writers::requests::*;
 use durs_common_tools::fatal_error;
 use durs_wot::NodeId;
@@ -31,6 +31,7 @@ use std::sync::mpsc;
 use std::thread;
 use std::time::SystemTime;
 use threadpool::ThreadPool;
+use unwrap::unwrap;
 
 /// Number of sync jobs
 pub static NB_SYNC_JOBS: &'static usize = &4;
@@ -152,7 +153,7 @@ pub fn local_sync<DC: DursConfTrait>(profile_path: PathBuf, conf: &DC, sync_opts
     conf.set_currency(currency.clone());
 
     // Get databases path
-    let db_path = durs_conf::get_blockchain_db_path(profile_path.clone(), &currency);
+    let db_path = durs_conf::get_blockchain_db_path(profile_path.clone());
 
     // Write new conf
     let mut conf_path = profile_path.clone();
@@ -207,7 +208,7 @@ pub fn local_sync<DC: DursConfTrait>(profile_path: PathBuf, conf: &DC, sync_opts
     );
 
     // Instantiate currency parameters
-    let mut currency_params = CurrencyParameters::default();
+    let mut currency_params = None;
 
     // Createprogess bar
     let mut apply_pb = ProgressBar::new(count_chunks.into());
@@ -225,7 +226,6 @@ pub fn local_sync<DC: DursConfTrait>(profile_path: PathBuf, conf: &DC, sync_opts
         recv_blocks_thread,
         blocks_dbs,
         forks_dbs,
-        currency_params.fork_window_size,
         target_blockstamp,
         apply_pb,
     );
@@ -234,7 +234,6 @@ pub fn local_sync<DC: DursConfTrait>(profile_path: PathBuf, conf: &DC, sync_opts
     apply::wot_worker::execute(
         &pool,
         profile_path.clone(),
-        currency.clone(),
         sender_sync_thread.clone(),
         recv_wot_thread,
     );
@@ -243,16 +242,12 @@ pub fn local_sync<DC: DursConfTrait>(profile_path: PathBuf, conf: &DC, sync_opts
     apply::txs_worker::execute(
         &pool,
         profile_path.clone(),
-        currency.clone(),
         sender_sync_thread.clone(),
         recv_tx_thread,
     );
 
     let main_job_begin = SystemTime::now();
 
-    // Open currency_params_db
-    let dbs_path = durs_conf::get_blockchain_db_path(profile_path, &conf.currency());
-
     // Apply blocks
     let mut blocks_not_expiring = VecDeque::with_capacity(200_000);
     let mut last_block_expiring: isize = -1;
@@ -279,25 +274,25 @@ pub fn local_sync<DC: DursConfTrait>(profile_path: PathBuf, conf: &DC, sync_opts
             .unwrap();
         // Get and write currency params
         if !get_currency_params {
+            let datas_path = durs_conf::get_datas_path(profile_path.clone());
             if block_doc.number == BlockNumber(0) {
-                currency_params =
+                currency_params = Some(
                     durs_blockchain_dal::readers::currency_params::get_and_write_currency_params(
-                        &dbs_path, &block_doc,
-                    );
+                        &datas_path,
+                        &block_doc,
+                    ),
+                );
             } else {
-                currency_params =
-                    match durs_blockchain_dal::readers::currency_params::get_currency_params(
-                        &dbs_path,
-                    ) {
-                        Ok(Some(currency_params)) => currency_params,
-                        Ok(None) => {
-                            fatal_error!("Params db corrupted: please reset data and resync !")
-                        }
-                        Err(_) => fatal_error!("Fail to open params db"),
-                    }
+                currency_params = match dup_currency_params::db::get_currency_params(datas_path) {
+                    Ok(Some((_currency_name, currency_params))) => Some(currency_params),
+                    Ok(None) => fatal_error!("Params db corrupted: please reset data and resync !"),
+                    Err(_) => fatal_error!("Fail to open params db"),
+                }
             }
             get_currency_params = true;
         }
+        let currency_params = unwrap!(currency_params);
+
         // Push block median_time in blocks_not_expiring
         blocks_not_expiring.push_back(block_doc.median_time);
         // Get blocks_expiring
diff --git a/lib/modules/skeleton/Cargo.toml b/lib/modules/skeleton/Cargo.toml
index a06369c6..2317ef47 100644
--- a/lib/modules/skeleton/Cargo.toml
+++ b/lib/modules/skeleton/Cargo.toml
@@ -10,11 +10,13 @@ edition = "2018"
 path = "lib.rs"
 
 [dependencies]
+dubp-documents= { path = "../../tools/documents" }
 durs-conf = { path = "../../core/conf" }
 durs-message =  { path = "../../core/message" }
 durs-module = { path = "../../core/module" }
 durs-network = { path = "../../core/network" }
 dup-crypto = { path = "../../tools/crypto" }
+dup-currency-params = { path = "../../tools/currency-params" }
 durs-common-tools = { path = "../../tools/common-tools" }
 failure = "0.1.5"
 log = "0.4.*"
diff --git a/lib/modules/skeleton/lib.rs b/lib/modules/skeleton/lib.rs
index b4ce23f2..394d5d02 100644
--- a/lib/modules/skeleton/lib.rs
+++ b/lib/modules/skeleton/lib.rs
@@ -34,6 +34,7 @@ extern crate serde_derive;
 #[macro_use]
 extern crate structopt;
 
+use dup_currency_params::CurrencyName;
 use durs_common_tools::fatal_error;
 use durs_common_tools::traits::merge::Merge;
 use durs_conf::DuRsConf;
@@ -139,6 +140,7 @@ impl DursModule<DuRsConf, DursMsg> for SkeletonModule {
         true
     }
     fn generate_module_conf(
+        _currency_name: Option<&CurrencyName>,
         _global_conf: &<DuRsConf as DursConfTrait>::GlobalConf,
         module_user_conf: Option<Self::ModuleUserConf>,
     ) -> Result<(Self::ModuleConf, Option<Self::ModuleUserConf>), ModuleConfError> {
diff --git a/lib/modules/tui/Cargo.toml b/lib/modules/tui/Cargo.toml
index 8f206570..5559d1ea 100644
--- a/lib/modules/tui/Cargo.toml
+++ b/lib/modules/tui/Cargo.toml
@@ -12,6 +12,7 @@ path = "lib.rs"
 [dependencies]
 durs-conf = { path = "../../core/conf" }
 dup-crypto = { path = "../../tools/crypto" }
+dup-currency-params = { path = "../../tools/currency-params" }
 dubp-documents= { path = "../../tools/documents" }
 durs-common-tools = { path = "../../tools/common-tools" }
 durs-message =  { path = "../../core/message" }
diff --git a/lib/modules/tui/lib.rs b/lib/modules/tui/lib.rs
index 791c9e27..83371a64 100644
--- a/lib/modules/tui/lib.rs
+++ b/lib/modules/tui/lib.rs
@@ -35,6 +35,7 @@ extern crate serde_derive;
 #[macro_use]
 extern crate structopt;
 
+use dup_currency_params::CurrencyName;
 use durs_common_tools::fatal_error;
 use durs_common_tools::traits::merge::Merge;
 use durs_conf::DuRsConf;
@@ -395,6 +396,7 @@ impl DursModule<DuRsConf, DursMsg> for TuiModule {
         RequiredKeys::None()
     }
     fn generate_module_conf(
+        _currency_name: Option<&CurrencyName>,
         _global_conf: &<DuRsConf as DursConfTrait>::GlobalConf,
         _module_user_conf: Option<Self::ModuleUserConf>,
     ) -> Result<(Self::ModuleConf, Option<Self::ModuleUserConf>), ModuleConfError> {
diff --git a/lib/modules/ws2p-v1-legacy/Cargo.toml b/lib/modules/ws2p-v1-legacy/Cargo.toml
index 83c7edaf..4c7944ef 100644
--- a/lib/modules/ws2p-v1-legacy/Cargo.toml
+++ b/lib/modules/ws2p-v1-legacy/Cargo.toml
@@ -17,6 +17,7 @@ durs-conf = { path = "../../core/conf" }
 durs-module = { path = "../../core/module" }
 durs-network = { path = "../../core/network" }
 dup-crypto = { path = "../../tools/crypto" }
+dup-currency-params = { path = "../../tools/currency-params" }
 durs-network-documents = { path = "../../tools/network-documents" }
 durs-message =  { path = "../../core/message" }
 durs-common-tools = { path = "../../tools/common-tools" }
diff --git a/lib/modules/ws2p-v1-legacy/src/lib.rs b/lib/modules/ws2p-v1-legacy/src/lib.rs
index c6ede1f2..218fb107 100644
--- a/lib/modules/ws2p-v1-legacy/src/lib.rs
+++ b/lib/modules/ws2p-v1-legacy/src/lib.rs
@@ -59,8 +59,9 @@ use crate::ws_connections::messages::WS2Pv1Msg;
 use crate::ws_connections::requests::{WS2Pv1ReqBody, WS2Pv1ReqFullId, WS2Pv1ReqId, WS2Pv1Request};
 use crate::ws_connections::states::WS2PConnectionState;
 use crate::ws_connections::*;
-use dubp_documents::{Blockstamp, CurrencyName};
+use dubp_documents::Blockstamp;
 use dup_crypto::keys::*;
+use dup_currency_params::CurrencyName;
 use durs_common_tools::fatal_error;
 use durs_common_tools::traits::merge::Merge;
 use durs_conf::DuRsConf;
@@ -126,6 +127,8 @@ impl Merge for WS2PUserConf {
 #[derive(Debug, Clone, PartialEq, Eq)]
 /// WS2P Configuration
 pub struct WS2PConf {
+    /// Currency name
+    pub currency: Option<CurrencyName>,
     /// Limit of outcoming connections
     pub outcoming_quota: usize,
     /// List of prefered public keys
@@ -137,6 +140,7 @@ pub struct WS2PConf {
 impl Default for WS2PConf {
     fn default() -> Self {
         WS2PConf {
+            currency: None,
             outcoming_quota: *WS2P_DEFAULT_OUTCOMING_QUOTA,
             prefered_pubkeys: HashSet::new(),
             sync_endpoints: vec![
@@ -220,7 +224,6 @@ pub enum SendRequestError {
 pub struct WS2Pv1Module {
     pub conf: WS2PConf,
     pub count_dal_requests: u32,
-    pub currency: Option<String>,
     pub current_blockstamp: Blockstamp,
     pub ep_file_path: PathBuf,
     pub heads_cache: HashMap<NodeFullId, NetworkHead>,
@@ -262,7 +265,6 @@ impl WS2Pv1Module {
         WS2Pv1Module {
             router_sender,
             key_pair,
-            currency: None,
             current_blockstamp: Blockstamp::default(),
             conf,
             ep_file_path,
@@ -398,12 +400,15 @@ impl DursModule<DuRsConf, DursMsg> for WS2Pv1Module {
     }
 
     fn generate_module_conf(
-        global_conf: &<DuRsConf as DursConfTrait>::GlobalConf,
+        currency_name: Option<&CurrencyName>,
+        _global_conf: &<DuRsConf as DursConfTrait>::GlobalConf,
         module_user_conf: Option<Self::ModuleUserConf>,
     ) -> Result<(Self::ModuleConf, Option<Self::ModuleUserConf>), ModuleConfError> {
         let mut conf = WS2PConf::default();
+        conf.currency = currency_name.cloned();
 
-        if global_conf.currency() == CurrencyName("g1-test".to_owned()) {
+        if currency_name.is_some() && unwrap!(currency_name) == &CurrencyName("g1-test".to_owned())
+        {
             conf.sync_endpoints = vec![
                 unwrap!(EndpointV1::parse_from_raw(
                     "WS2P 3eaab4c7 ts.gt.librelois.fr 443 /ws2p",
@@ -502,10 +507,7 @@ impl DursModule<DuRsConf, DursMsg> for WS2Pv1Module {
         }
 
         // Get endpoints file path
-        let mut ep_file_path = durs_conf::datas_path(
-            soft_meta_datas.profile_path.clone(),
-            &soft_meta_datas.conf.currency(),
-        );
+        let mut ep_file_path = durs_conf::get_datas_path(soft_meta_datas.profile_path.clone());
         ep_file_path.push("ws2pv1");
         if !ep_file_path.exists() {
             fs::create_dir(ep_file_path.as_path()).expect("Impossible to create ws2pv1 dir !");
@@ -520,14 +522,13 @@ impl DursModule<DuRsConf, DursMsg> for WS2Pv1Module {
             key_pair,
             router_sender.clone(),
         );
-        ws2p_module.currency = Some(soft_meta_datas.conf.currency().to_string());
         ws2p_module.ws2p_endpoints = ws2p_endpoints;
 
         // Create ws2p main thread channel
         let ws2p_sender_clone = ws2p_module.main_thread_channel.0.clone();
 
         // Get ws2p endpoints in file
-        info!("TMP: WS2P SSL={}", ssl());
+        debug!("WS2P SSL={}", ssl());
         let count;
         match ws2p_db::get_endpoints(&ep_file_path) {
             Ok(ws2p_enpoints) => {
diff --git a/lib/modules/ws2p-v1-legacy/src/parsers/blocks.rs b/lib/modules/ws2p-v1-legacy/src/parsers/blocks.rs
index 0baf44a6..75143b30 100644
--- a/lib/modules/ws2p-v1-legacy/src/parsers/blocks.rs
+++ b/lib/modules/ws2p-v1-legacy/src/parsers/blocks.rs
@@ -2,14 +2,15 @@ use super::excluded::parse_exclusions_from_json_value;
 use super::identities::parse_compact_identity;
 use super::transactions::parse_transaction;
 use dubp_documents::documents::block::BlockDocument;
-use dubp_documents::documents::block::{BlockV10Parameters, TxDocOrTxHash};
+use dubp_documents::documents::block::TxDocOrTxHash;
 use dubp_documents::documents::membership::*;
 use dubp_documents::parsers::certifications::*;
 use dubp_documents::parsers::revoked::*;
-use dubp_documents::CurrencyName;
 use dubp_documents::{BlockHash, BlockNumber};
 use dup_crypto::hashs::Hash;
 use dup_crypto::keys::*;
+use dup_currency_params::genesis_block_params::v10::BlockV10Parameters;
+use dup_currency_params::CurrencyName;
 use std::str::FromStr;
 
 fn parse_previous_hash(block_number: BlockNumber, source: &serde_json::Value) -> Option<Hash> {
diff --git a/lib/modules/ws2p-v1-legacy/src/ws_connections/mod.rs b/lib/modules/ws2p-v1-legacy/src/ws_connections/mod.rs
index eb35567f..3ff11ed6 100644
--- a/lib/modules/ws2p-v1-legacy/src/ws_connections/mod.rs
+++ b/lib/modules/ws2p-v1-legacy/src/ws_connections/mod.rs
@@ -134,13 +134,13 @@ pub fn connect_to_without_checking_quotas(
     let endpoint = unwrap!(ws2p_module.ws2p_endpoints.get(&node_full_id));
     let endpoint_copy = endpoint.ep.clone();
     let conductor_sender_copy = ws2p_module.main_thread_channel.0.clone();
-    let currency_copy = ws2p_module.currency.clone();
+    let currency_copy = ws2p_module.conf.currency.clone();
     let key_pair_copy = ws2p_module.key_pair;
     thread::spawn(move || {
         let _result = crate::ws_connections::handler::connect_to_ws2p_endpoint(
             &endpoint_copy,
             &conductor_sender_copy,
-            &currency_copy.expect("WS2PError : No currency !"),
+            &currency_copy.expect("WS2PError : No currency !").0,
             key_pair_copy,
         );
     });
diff --git a/lib/modules/ws2p/ws2p-messages/Cargo.toml b/lib/modules/ws2p/ws2p-messages/Cargo.toml
index b9588ba5..5b65ecc4 100644
--- a/lib/modules/ws2p/ws2p-messages/Cargo.toml
+++ b/lib/modules/ws2p/ws2p-messages/Cargo.toml
@@ -13,6 +13,7 @@ path = "lib.rs"
 bincode = "1.0.*"
 byteorder = "1.2.3"
 dup-crypto = { path = "../../../tools/crypto" }
+dup-currency-params = { path = "../../../tools/currency-params" }
 dubp-documents= { path = "../../../tools/documents" }
 durs-network-documents = { path = "../../../tools/network-documents" }
 durs-common-tools = { path = "../../../tools/common-tools" }
diff --git a/lib/modules/ws2p/ws2p-messages/lib.rs b/lib/modules/ws2p/ws2p-messages/lib.rs
index 0a7fa10e..a4bcf820 100644
--- a/lib/modules/ws2p/ws2p-messages/lib.rs
+++ b/lib/modules/ws2p/ws2p-messages/lib.rs
@@ -173,9 +173,10 @@ mod tests {
     use bincode;
     use bincode::{deserialize, serialize};
     use dubp_documents::documents::certification::*;
-    use dubp_documents::{Blockstamp, CurrencyName};
+    use dubp_documents::Blockstamp;
     use dup_crypto::keys::bin_signable::BinSignable;
     use dup_crypto::keys::*;
+    use dup_currency_params::CurrencyName;
     use durs_network_documents::network_endpoint::*;
     use durs_network_documents::network_peer::*;
     use durs_network_documents::*;
diff --git a/lib/modules/ws2p/ws2p-messages/v2/mod.rs b/lib/modules/ws2p/ws2p-messages/v2/mod.rs
index 412d3345..59e1b696 100644
--- a/lib/modules/ws2p/ws2p-messages/v2/mod.rs
+++ b/lib/modules/ws2p/ws2p-messages/v2/mod.rs
@@ -30,10 +30,10 @@ pub mod secret_flags;
 
 use crate::v2::payload_container::*;
 use crate::WS2PMessage;
-use dubp_documents::CurrencyName;
 use dup_crypto::hashs::Hash;
 use dup_crypto::keys::bin_signable::BinSignable;
 use dup_crypto::keys::*;
+use dup_currency_params::CurrencyName;
 use durs_network_documents::NodeId;
 
 /// WS2P v2 message metadata size
diff --git a/lib/modules/ws2p/ws2p-protocol/Cargo.toml b/lib/modules/ws2p/ws2p-protocol/Cargo.toml
index 3a0cb5bb..b7d0235d 100644
--- a/lib/modules/ws2p/ws2p-protocol/Cargo.toml
+++ b/lib/modules/ws2p/ws2p-protocol/Cargo.toml
@@ -11,6 +11,7 @@ path = "src/lib.rs"
 
 [dependencies]
 dup-crypto = { path = "../../../tools/crypto" }
+dup-currency-params = { path = "../../../tools/currency-params" }
 durs-common-tools = { path = "../../../tools/common-tools" }
 dubp-documents= { path = "../../../tools/documents" }
 durs-module = { path = "../../../core/module" }
diff --git a/lib/modules/ws2p/ws2p-protocol/src/controller/meta_datas.rs b/lib/modules/ws2p/ws2p-protocol/src/controller/meta_datas.rs
index 3550f756..27f1fca4 100644
--- a/lib/modules/ws2p/ws2p-protocol/src/controller/meta_datas.rs
+++ b/lib/modules/ws2p/ws2p-protocol/src/controller/meta_datas.rs
@@ -17,8 +17,9 @@
 
 use crate::connection_state::WS2PConnectionState;
 use crate::MySelfWs2pNode;
-use dubp_documents::{Blockstamp, CurrencyName};
+use dubp_documents::Blockstamp;
 use dup_crypto::hashs::Hash;
+use dup_currency_params::CurrencyName;
 use durs_network_documents::network_peer::PeerCardV11;
 use durs_network_documents::NodeFullId;
 use durs_ws2p_messages::v2::api_features::WS2PFeatures;
diff --git a/lib/modules/ws2p/ws2p-protocol/src/controller/on_message/connect_msg.rs b/lib/modules/ws2p/ws2p-protocol/src/controller/on_message/connect_msg.rs
index 857f6256..b2bdb7ee 100644
--- a/lib/modules/ws2p/ws2p-protocol/src/controller/on_message/connect_msg.rs
+++ b/lib/modules/ws2p/ws2p-protocol/src/controller/on_message/connect_msg.rs
@@ -46,10 +46,6 @@ pub fn process_ws2p_v2p_connect_msg<M: ModuleMessage>(
     };
 
     if let WS2PConnectionState::WaitingConnectMsg = controller.meta_datas.state {
-        log::info!(
-            "TMP DEBUG: my_connect_type={:?}",
-            controller.meta_datas.connect_type
-        );
         // Check remote node datas
         if let WS2Pv2ConnectType::Incoming = controller.meta_datas.connect_type {
             controller.meta_datas.remote_node = Some(remote_node_datas);
@@ -60,8 +56,6 @@ pub fn process_ws2p_v2p_connect_msg<M: ModuleMessage>(
             ));
         } else {
             let expected_full_id = unwrap!(controller.id.expected_remote_full_id());
-            log::info!("TMP DEBUG: remote_full_id={}", remote_full_id);
-            log::info!("TMP DEBUG: expected_full_id={}", expected_full_id);
             if remote_full_id == expected_full_id {
                 controller.meta_datas.remote_node = Some(remote_node_datas);
             } else {
diff --git a/lib/modules/ws2p/ws2p/Cargo.toml b/lib/modules/ws2p/ws2p/Cargo.toml
index 82e7e371..828df221 100644
--- a/lib/modules/ws2p/ws2p/Cargo.toml
+++ b/lib/modules/ws2p/ws2p/Cargo.toml
@@ -13,6 +13,7 @@ path = "src/lib.rs"
 bincode = "1.0.*"
 durs-conf= { path = "../../../core/conf" }
 dup-crypto = { path = "../../../tools/crypto" }
+dup-currency-params = { path = "../../../tools/currency-params" }
 dubp-documents= { path = "../../../tools/documents" }
 durs-network-documents = { path = "../../../tools/network-documents" }
 durs-common-tools = { path = "../../../tools/common-tools" }
diff --git a/lib/modules/ws2p/ws2p/src/controllers/incoming_connections.rs b/lib/modules/ws2p/ws2p/src/controllers/incoming_connections.rs
index 75b33ec1..0aa3e404 100644
--- a/lib/modules/ws2p/ws2p/src/controllers/incoming_connections.rs
+++ b/lib/modules/ws2p/ws2p/src/controllers/incoming_connections.rs
@@ -17,7 +17,7 @@
 
 use crate::controllers::handler::Ws2pConnectionHandler;
 use crate::controllers::*;
-use dubp_documents::CurrencyName;
+use dup_currency_params::CurrencyName;
 use durs_common_tools::fatal_error;
 use durs_message::DursMsg;
 use durs_ws2p_messages::v2::connect::WS2Pv2ConnectType;
diff --git a/lib/modules/ws2p/ws2p/src/controllers/outgoing_connections.rs b/lib/modules/ws2p/ws2p/src/controllers/outgoing_connections.rs
index b64cbdd7..525a53ef 100644
--- a/lib/modules/ws2p/ws2p/src/controllers/outgoing_connections.rs
+++ b/lib/modules/ws2p/ws2p/src/controllers/outgoing_connections.rs
@@ -17,7 +17,7 @@
 
 use crate::controllers::handler::Ws2pConnectionHandler;
 use crate::controllers::*;
-use dubp_documents::CurrencyName;
+use dup_currency_params::CurrencyName;
 use durs_common_tools::fatal_error;
 use durs_message::DursMsg;
 use durs_network_documents::network_endpoint::EndpointEnum;
diff --git a/lib/modules/ws2p/ws2p/src/generate_peer.rs b/lib/modules/ws2p/ws2p/src/generate_peer.rs
index fcbd3537..fa217973 100644
--- a/lib/modules/ws2p/ws2p/src/generate_peer.rs
+++ b/lib/modules/ws2p/ws2p/src/generate_peer.rs
@@ -16,8 +16,9 @@
 //! Generate self peer card
 
 use bincode;
-use dubp_documents::{Blockstamp, CurrencyName};
+use dubp_documents::Blockstamp;
 use dup_crypto::keys::PubKey;
+use dup_currency_params::CurrencyName;
 use durs_common_tools::fatal_error;
 use durs_network_documents::network_endpoint::*;
 use durs_network_documents::network_peer::*;
diff --git a/lib/modules/ws2p/ws2p/src/lib.rs b/lib/modules/ws2p/ws2p/src/lib.rs
index 50528fef..1118c3e6 100644
--- a/lib/modules/ws2p/ws2p/src/lib.rs
+++ b/lib/modules/ws2p/ws2p/src/lib.rs
@@ -40,6 +40,7 @@ mod generate_peer;
 pub mod services;
 
 use crate::errors::WS2PError;
+use dup_currency_params::CurrencyName;
 use durs_common_tools::fatal_error;
 use durs_common_tools::traits::merge::Merge;
 use durs_conf::DuRsConf;
@@ -171,6 +172,7 @@ impl DursModule<DuRsConf, DursMsg> for WS2PModule {
         true
     }
     fn generate_module_conf(
+        _currency_name: Option<&CurrencyName>,
         _global_conf: &<DuRsConf as DursConfTrait>::GlobalConf,
         module_user_conf: Option<Self::ModuleUserConf>,
     ) -> Result<(Self::ModuleConf, Option<Self::ModuleUserConf>), ModuleConfError> {
diff --git a/lib/modules/ws2p/ws2p/src/services/outgoing.rs b/lib/modules/ws2p/ws2p/src/services/outgoing.rs
index 7deb400d..abecf71c 100644
--- a/lib/modules/ws2p/ws2p/src/services/outgoing.rs
+++ b/lib/modules/ws2p/ws2p/src/services/outgoing.rs
@@ -17,7 +17,7 @@
 
 use crate::services::WsError;
 use crate::*;
-use dubp_documents::CurrencyName;
+use dup_currency_params::CurrencyName;
 use durs_network_documents::{NodeFullId, NodeId};
 use durs_ws2p_protocol::connection_state::WS2PConnectionState;
 use durs_ws2p_protocol::controller::WebsocketActionOrder;
diff --git a/lib/modules/ws2p/ws2p/tests/connection_negociation.rs b/lib/modules/ws2p/ws2p/tests/connection_negociation.rs
index 5580755c..49b8d211 100644
--- a/lib/modules/ws2p/ws2p/tests/connection_negociation.rs
+++ b/lib/modules/ws2p/ws2p/tests/connection_negociation.rs
@@ -13,9 +13,9 @@
 // You should have received a copy of the GNU Affero General Public License
 // along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-use dubp_documents::CurrencyName;
 use dup_crypto::keys::KeyPair;
 use dup_crypto::keys::*;
+use dup_currency_params::CurrencyName;
 //use durs_common_tests_tools::logger::init_logger_stdout;
 use durs_message::DursMsg;
 use durs_network_documents::network_endpoint::*;
diff --git a/lib/tests-tools/documents-tests-tools/Cargo.toml b/lib/tests-tools/documents-tests-tools/Cargo.toml
index fc995d31..91564cc2 100644
--- a/lib/tests-tools/documents-tests-tools/Cargo.toml
+++ b/lib/tests-tools/documents-tests-tools/Cargo.toml
@@ -14,6 +14,7 @@ path = "src/lib.rs"
 
 [dependencies]
 dup-crypto = { path = "../../tools/crypto" }
+dup-currency-params = { path = "../../tools/currency-params" }
 dubp-documents = { path = "../../tools/documents" }
 dup-crypto-tests-tools = { path = "../crypto-tests-tools" }
 
diff --git a/lib/tests-tools/documents-tests-tools/src/mocks/mod.rs b/lib/tests-tools/documents-tests-tools/src/mocks/mod.rs
index 6f832f1d..9020a8ce 100644
--- a/lib/tests-tools/documents-tests-tools/src/mocks/mod.rs
+++ b/lib/tests-tools/documents-tests-tools/src/mocks/mod.rs
@@ -20,6 +20,7 @@ pub mod identity;
 use dubp_documents::documents::block::BlockDocument;
 use dubp_documents::*;
 use dup_crypto::hashs::Hash;
+use dup_currency_params::CurrencyName;
 
 /// Generate n mock blockstamps
 pub fn generate_blockstamps(n: usize) -> Vec<Blockstamp> {
@@ -75,7 +76,7 @@ pub fn gen_empty_timed_block(
         issuers_count: 0,
         issuers_frame: 0,
         issuers_frame_var: 0,
-        currency: CurrencyName::default(),
+        currency: CurrencyName("test_currency".to_owned()),
         issuers: vec![],
         signatures: vec![],
         hash: Some(blockstamp.hash),
diff --git a/lib/tools/currency-params/Cargo.toml b/lib/tools/currency-params/Cargo.toml
index 7a3c2bd2..0bf35166 100644
--- a/lib/tools/currency-params/Cargo.toml
+++ b/lib/tools/currency-params/Cargo.toml
@@ -12,4 +12,7 @@ edition = "2018"
 path = "src/lib.rs"
 
 [dependencies]
-dubp-documents= { path = "../documents" }
+bincode = "1.0.1"
+durs-common-tools = { path = "../common-tools" }
+failure = "0.1.5"
+serde = { version = "1.0.*", features = ["derive"] }
diff --git a/lib/tools/currency-params/src/constants.rs b/lib/tools/currency-params/src/constants.rs
index af9b3e24..73b106ce 100644
--- a/lib/tools/currency-params/src/constants.rs
+++ b/lib/tools/currency-params/src/constants.rs
@@ -15,6 +15,9 @@
 
 //! Currency parameters constants.
 
+/// Currency params DB name
+pub const CURRENCY_PARAMS_DB_NAME: &str = "currency_params.db";
+
 /// Default currency name
 pub const DEFAULT_CURRENCY: &str = "default_currency";
 /// Default value for sig_renew_period parameter
diff --git a/lib/tools/currency-params/src/currencies_codes.rs b/lib/tools/currency-params/src/currencies_codes.rs
new file mode 100644
index 00000000..19bfaaaf
--- /dev/null
+++ b/lib/tools/currency-params/src/currencies_codes.rs
@@ -0,0 +1,73 @@
+//  Copyright (C) 2018  The Duniter Project Developers.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+//! Implements the Duniter Documents Protocol.
+
+use crate::CurrencyName;
+use serde::{Deserialize, Serialize};
+use std::convert::{TryFrom, TryInto};
+
+/// CURRENCY_NULL
+const CURRENCY_NULL: u16 = 0x_0000;
+/// CURRENCY_G1
+const CURRENCY_G1: u16 = 0x_0001;
+/// CURRENCY_G1_TEST
+const CURRENCY_G1_TEST: u16 = 0x_1000;
+
+/// CurrencyCodeError
+#[derive(Debug)]
+pub enum CurrencyCodeError {
+    /// UnknowCurrencyCode
+    UnknowCurrencyCode,
+    /// IoError
+    IoError(std::io::Error),
+    /// UnknowCurrencyName
+    UnknowCurrencyName,
+}
+
+impl From<std::io::Error> for CurrencyCodeError {
+    fn from(error: std::io::Error) -> Self {
+        CurrencyCodeError::IoError(error)
+    }
+}
+
+#[derive(Debug, Copy, Clone, Eq, PartialEq, Deserialize, Serialize, Hash)]
+/// Currency code
+pub struct CurrencyCode(u16);
+
+impl TryFrom<CurrencyName> for CurrencyCode {
+    type Error = CurrencyCodeError;
+
+    fn try_from(currency_name: CurrencyName) -> Result<Self, Self::Error> {
+        match currency_name.0.as_str() {
+            "g1" => Ok(CurrencyCode(CURRENCY_G1)),
+            "g1-test" => Ok(CurrencyCode(CURRENCY_G1_TEST)),
+            _ => Err(CurrencyCodeError::UnknowCurrencyName),
+        }
+    }
+}
+
+impl TryInto<CurrencyName> for CurrencyCode {
+    type Error = CurrencyCodeError;
+
+    fn try_into(self) -> Result<CurrencyName, Self::Error> {
+        match self.0 {
+            CURRENCY_NULL => Ok(CurrencyName("".to_owned())),
+            CURRENCY_G1 => Ok(CurrencyName("g1".to_owned())),
+            CURRENCY_G1_TEST => Ok(CurrencyName("g1-test".to_owned())),
+            _ => Err(CurrencyCodeError::UnknowCurrencyCode),
+        }
+    }
+}
diff --git a/lib/tools/currency-params/src/db.rs b/lib/tools/currency-params/src/db.rs
new file mode 100644
index 00000000..b2e6a1b2
--- /dev/null
+++ b/lib/tools/currency-params/src/db.rs
@@ -0,0 +1,101 @@
+//  Copyright (C) 2018  The Durs Project Developers.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+//! Duniter protocol currency parameters DB
+
+use crate::constants::CURRENCY_PARAMS_DB_NAME;
+use crate::genesis_block_params::GenesisBlockParams;
+use crate::{CurrencyName, CurrencyParameters};
+use durs_common_tools::fns::bin_file::{read_bin_file, write_bin_file};
+use failure::Fail;
+use std::path::PathBuf;
+
+/// Currency parameters db datas
+type CurrencyParamsDbDatas = Option<(CurrencyName, GenesisBlockParams)>;
+
+/// Currency params Db error
+#[derive(Debug, Fail)]
+pub enum CurrencyParamsDbError {
+    /// Serialize/Deserialize error
+    #[fail(display = "SerDe error: {}", _0)]
+    SerDe(bincode::Error),
+    /// I/O Error
+    #[fail(display = "I/O error: {}", _0)]
+    Io(std::io::Error),
+}
+
+/// Get currency name
+pub fn get_currency_name(
+    datas_path: PathBuf,
+) -> Result<Option<CurrencyName>, CurrencyParamsDbError> {
+    let db_datas: CurrencyParamsDbDatas = read_currency_params_db(datas_path)?;
+
+    if let Some((currency_name, _genesis_block_params)) = db_datas {
+        Ok(Some(currency_name))
+    } else {
+        Ok(None)
+    }
+}
+
+/// Get currency parameters
+pub fn get_currency_params(
+    datas_path: PathBuf,
+) -> Result<Option<(CurrencyName, CurrencyParameters)>, CurrencyParamsDbError> {
+    let db_datas: CurrencyParamsDbDatas = read_currency_params_db(datas_path)?;
+
+    if let Some((currency_name, genesis_block_params)) = db_datas {
+        let currency_params = match genesis_block_params {
+            GenesisBlockParams::V10(genesis_block_v10_params) => {
+                CurrencyParameters::from((&currency_name, genesis_block_v10_params))
+            }
+        };
+        Ok(Some((currency_name, currency_params)))
+    } else {
+        Ok(None)
+    }
+}
+
+fn read_currency_params_db(
+    mut datas_path: PathBuf,
+) -> Result<CurrencyParamsDbDatas, CurrencyParamsDbError> {
+    datas_path.push(CURRENCY_PARAMS_DB_NAME);
+
+    if !datas_path.exists() {
+        return Ok(None);
+    }
+
+    let bin_vec = read_bin_file(datas_path.as_path()).map_err(CurrencyParamsDbError::Io)?;
+    let db_datas: CurrencyParamsDbDatas =
+        bincode::deserialize(&bin_vec).map_err(CurrencyParamsDbError::SerDe)?;
+
+    Ok(db_datas)
+}
+
+/// Write currency parameters
+pub fn write_currency_params(
+    mut datas_path: PathBuf,
+    currency_name: CurrencyName,
+    genesis_block_params: GenesisBlockParams,
+) -> Result<(), CurrencyParamsDbError> {
+    datas_path.push(CURRENCY_PARAMS_DB_NAME);
+
+    let db_datas: CurrencyParamsDbDatas = Some((currency_name, genesis_block_params));
+
+    Ok(write_bin_file(
+        datas_path.as_path(),
+        &bincode::serialize(&db_datas).map_err(CurrencyParamsDbError::SerDe)?,
+    )
+    .map_err(CurrencyParamsDbError::Io)?)
+}
diff --git a/lib/tools/currency-params/src/genesis_block_params.rs b/lib/tools/currency-params/src/genesis_block_params.rs
new file mode 100644
index 00000000..c29ef4b2
--- /dev/null
+++ b/lib/tools/currency-params/src/genesis_block_params.rs
@@ -0,0 +1,52 @@
+//  Copyright (C) 2018  The Durs Project Developers.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+//! Duniter protocol currency parameters in genesis block
+
+pub mod v10;
+
+use failure::Fail;
+use serde::{Deserialize, Serialize};
+use v10::BlockV10Parameters;
+
+#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
+/// Currency parameters in genesis block
+pub enum GenesisBlockParams {
+    /// Currency parameters in genesis block v10
+    V10(BlockV10Parameters),
+}
+
+#[derive(Debug, Clone, Fail)]
+/// Store error in block parameters parsing
+pub enum ParseParamsError {
+    /// ParseIntError
+    #[fail(display = "Fail to parse params :ParseIntError !")]
+    ParseIntError(::std::num::ParseIntError),
+    /// ParseFloatError
+    #[fail(display = "Fail to parse params :ParseFloatError !")]
+    ParseFloatError(::std::num::ParseFloatError),
+}
+
+impl From<::std::num::ParseIntError> for ParseParamsError {
+    fn from(err: ::std::num::ParseIntError) -> ParseParamsError {
+        ParseParamsError::ParseIntError(err)
+    }
+}
+
+impl From<::std::num::ParseFloatError> for ParseParamsError {
+    fn from(err: ::std::num::ParseFloatError) -> ParseParamsError {
+        ParseParamsError::ParseFloatError(err)
+    }
+}
diff --git a/lib/tools/currency-params/src/genesis_block_params/v10.rs b/lib/tools/currency-params/src/genesis_block_params/v10.rs
new file mode 100644
index 00000000..dbc0bada
--- /dev/null
+++ b/lib/tools/currency-params/src/genesis_block_params/v10.rs
@@ -0,0 +1,153 @@
+//  Copyright (C) 2018  The Durs Project Developers.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+//! Duniter protocol currency parameters in genesis block v10
+
+use crate::genesis_block_params::ParseParamsError;
+use serde::{Deserialize, Serialize};
+
+/// Currency parameters
+#[derive(Debug, Copy, Clone, Deserialize, Serialize, PartialEq)]
+pub struct BlockV10Parameters {
+    /// UD target growth rate (see Relative Theorie of Money)
+    pub c: f64,
+    /// Duration between the creation of two UD (in seconds)
+    pub dt: u64,
+    /// Amount of the initial UD
+    pub ud0: usize,
+    /// Minimum duration between the writing of 2 certifications from the same issuer (in seconds)
+    pub sig_period: u64,
+    /// Maximum number of active certifications at the same time (for the same issuer)
+    pub sig_stock: usize,
+    /// Maximum retention period of a pending certification
+    pub sig_window: u64,
+    /// Time to expiry of written certification
+    pub sig_validity: u64,
+    /// Minimum number of certifications required to become a member
+    pub sig_qty: usize,
+    /// Maximum retention period of a pending identity
+    pub idty_window: u64,
+    /// Maximum retention period of a pending membership
+    pub ms_window: u64,
+    /// Percentage of referring members who must be within step_max steps of each member
+    pub x_percent: f64,
+    /// Time to expiry of written membership
+    pub ms_validity: u64,
+    /// For a member to respect the distance rule,
+    /// there must exist for more than x_percent % of the referring members
+    /// a path of less than step_max steps from the referring member to the evaluated member.
+    pub step_max: usize,
+    /// Number of blocks used for calculating median time.
+    pub median_time_blocks: usize,
+    /// The average time for writing 1 block (wished time)
+    pub avg_gen_time: u64,
+    /// The number of blocks required to evaluate again PoWMin value
+    pub dt_diff_eval: usize,
+    /// The percent of previous issuers to reach for personalized difficulty
+    pub percent_rot: f64,
+    /// Time of first UD.
+    pub ud_time0: u64,
+    /// Time of first reevaluation of the UD.
+    pub ud_reeval_time0: u64,
+    /// Time period between two re-evaluation of the UD.
+    pub dt_reeval: u64,
+}
+
+impl Default for BlockV10Parameters {
+    fn default() -> BlockV10Parameters {
+        BlockV10Parameters {
+            c: 0.0488,
+            dt: 86_400,
+            ud0: 1_000,
+            sig_period: 432_000,
+            sig_stock: 100,
+            sig_window: 5_259_600,
+            sig_validity: 63_115_200,
+            sig_qty: 5,
+            idty_window: 5_259_600,
+            ms_window: 5_259_600,
+            x_percent: 0.8,
+            ms_validity: 31_557_600,
+            step_max: 5,
+            median_time_blocks: 24,
+            avg_gen_time: 300,
+            dt_diff_eval: 12,
+            percent_rot: 0.67,
+            ud_time0: 1_488_970_800,
+            ud_reeval_time0: 1_490_094_000,
+            dt_reeval: 15_778_800,
+        }
+    }
+}
+
+impl ::std::str::FromStr for BlockV10Parameters {
+    type Err = ParseParamsError;
+
+    fn from_str(source: &str) -> Result<Self, Self::Err> {
+        let params: Vec<&str> = source.split(':').collect();
+        Ok(BlockV10Parameters {
+            c: params[0].parse()?,
+            dt: params[1].parse()?,
+            ud0: params[2].parse()?,
+            sig_period: params[3].parse()?,
+            sig_stock: params[4].parse()?,
+            sig_window: params[5].parse()?,
+            sig_validity: params[6].parse()?,
+            sig_qty: params[7].parse()?,
+            idty_window: params[8].parse()?,
+            ms_window: params[9].parse()?,
+            x_percent: params[10].parse()?,
+            ms_validity: params[11].parse()?,
+            step_max: params[12].parse()?,
+            median_time_blocks: params[13].parse()?,
+            avg_gen_time: params[14].parse()?,
+            dt_diff_eval: params[15].parse()?,
+            percent_rot: params[16].parse()?,
+            ud_time0: params[17].parse()?,
+            ud_reeval_time0: params[18].parse()?,
+            dt_reeval: params[19].parse()?,
+        })
+    }
+}
+
+impl ToString for BlockV10Parameters {
+    fn to_string(&self) -> String {
+        format!(
+            "{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}",
+            self.c,
+            self.dt,
+            self.ud0,
+            self.sig_period,
+            self.sig_stock,
+            self.sig_window,
+            self.sig_validity,
+            self.sig_qty,
+            self.idty_window,
+            self.ms_window,
+            self.x_percent,
+            self.ms_validity,
+            self.step_max,
+            self.median_time_blocks,
+            self.avg_gen_time,
+            self.dt_diff_eval,
+            self.percent_rot,
+            self.ud_time0,
+            self.ud_reeval_time0,
+            self.dt_reeval,
+        )
+    }
+}
+
+impl Eq for BlockV10Parameters {}
diff --git a/lib/tools/currency-params/src/lib.rs b/lib/tools/currency-params/src/lib.rs
index 04108301..e566fdc7 100644
--- a/lib/tools/currency-params/src/lib.rs
+++ b/lib/tools/currency-params/src/lib.rs
@@ -15,11 +15,36 @@
 
 //! Duniter protocol currency parameters
 
+#![deny(
+    missing_docs,
+    missing_debug_implementations,
+    missing_copy_implementations,
+    trivial_casts,
+    trivial_numeric_casts,
+    unsafe_code,
+    unstable_features,
+    unused_import_braces
+)]
+
 pub mod constants;
+pub mod currencies_codes;
+pub mod db;
+pub mod genesis_block_params;
 
 use crate::constants::*;
-use dubp_documents::documents::block::BlockV10Parameters;
-use dubp_documents::CurrencyName;
+use genesis_block_params::v10::BlockV10Parameters;
+use serde::{Deserialize, Serialize};
+use std::fmt::{Display, Error, Formatter};
+
+/// Currency name
+#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize, Hash)]
+pub struct CurrencyName(pub String);
+
+impl Display for CurrencyName {
+    fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
+        write!(f, "{}", self.0)
+    }
+}
 
 #[derive(Debug, Copy, Clone)]
 /// Currency parameters
@@ -78,8 +103,8 @@ pub struct CurrencyParameters {
     pub fork_window_size: usize,
 }
 
-impl From<(CurrencyName, BlockV10Parameters)> for CurrencyParameters {
-    fn from(source: (CurrencyName, BlockV10Parameters)) -> CurrencyParameters {
+impl From<(&CurrencyName, BlockV10Parameters)> for CurrencyParameters {
+    fn from(source: (&CurrencyName, BlockV10Parameters)) -> CurrencyParameters {
         let (currency_name, block_params) = source;
         let sig_renew_period = match currency_name.0.as_str() {
             DEFAULT_CURRENCY => *DEFAULT_SIG_RENEW_PERIOD,
@@ -135,15 +160,6 @@ impl From<(CurrencyName, BlockV10Parameters)> for CurrencyParameters {
     }
 }
 
-impl Default for CurrencyParameters {
-    fn default() -> CurrencyParameters {
-        CurrencyParameters::from((
-            CurrencyName(String::from(DEFAULT_CURRENCY)),
-            BlockV10Parameters::default(),
-        ))
-    }
-}
-
 impl CurrencyParameters {
     /// Get max value of connectivity (=1/x_percent)
     pub fn max_connectivity(&self) -> f64 {
diff --git a/lib/tools/documents/Cargo.toml b/lib/tools/documents/Cargo.toml
index bd20e526..3e9ca1d8 100644
--- a/lib/tools/documents/Cargo.toml
+++ b/lib/tools/documents/Cargo.toml
@@ -13,9 +13,9 @@ edition = "2018"
 path = "src/lib.rs"
 
 [dependencies]
-byteorder = "1.2.3"
 durs-common-tools = { path = "../common-tools" }
 dup-crypto = { path = "../crypto" }
+dup-currency-params = { path = "../currency-params" }
 failure = "0.1.5"
 json-pest-parser = { path = "../json-pest-parser" }
 pest = "2.1.0"
diff --git a/lib/tools/documents/src/currencies_codes.rs b/lib/tools/documents/src/currencies_codes.rs
deleted file mode 100644
index 87949831..00000000
--- a/lib/tools/documents/src/currencies_codes.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-//  Copyright (C) 2018  The Duniter Project Developers.
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Affero General Public License as
-// published by the Free Software Foundation, either version 3 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU Affero General Public License for more details.
-//
-// You should have received a copy of the GNU Affero General Public License
-// along with this program.  If not, see <https://www.gnu.org/licenses/>.
-
-//! Implements the Duniter Documents Protocol.
-
-/// CURRENCY_NULL
-pub static CURRENCY_NULL: &'static u16 = &0x_0000;
-/// CURRENCY_G1
-pub static CURRENCY_G1: &'static u16 = &0x_0001;
-/// CURRENCY_G1_TEST
-pub static CURRENCY_G1_TEST: &'static u16 = &0x_1000;
diff --git a/lib/tools/documents/src/documents/block.rs b/lib/tools/documents/src/documents/block.rs
index 8d821a75..eed6d4eb 100644
--- a/lib/tools/documents/src/documents/block.rs
+++ b/lib/tools/documents/src/documents/block.rs
@@ -17,6 +17,8 @@
 
 use dup_crypto::hashs::Hash;
 use dup_crypto::keys::*;
+use dup_currency_params::genesis_block_params::v10::BlockV10Parameters;
+use dup_currency_params::CurrencyName;
 use durs_common_tools::fatal_error;
 use std::ops::Deref;
 
@@ -29,163 +31,6 @@ use crate::documents::transaction::TransactionDocument;
 use crate::documents::*;
 use crate::text_document_traits::*;
 
-#[derive(Debug, Clone, Fail)]
-/// Store error in block parameters parsing
-pub enum ParseParamsError {
-    /// ParseIntError
-    #[fail(display = "Fail to parse params :ParseIntError !")]
-    ParseIntError(::std::num::ParseIntError),
-    /// ParseFloatError
-    #[fail(display = "Fail to parse params :ParseFloatError !")]
-    ParseFloatError(::std::num::ParseFloatError),
-}
-
-impl From<::std::num::ParseIntError> for ParseParamsError {
-    fn from(err: ::std::num::ParseIntError) -> ParseParamsError {
-        ParseParamsError::ParseIntError(err)
-    }
-}
-
-impl From<::std::num::ParseFloatError> for ParseParamsError {
-    fn from(err: ::std::num::ParseFloatError) -> ParseParamsError {
-        ParseParamsError::ParseFloatError(err)
-    }
-}
-
-/// Currency parameters
-#[derive(Debug, Copy, Clone, Deserialize, Serialize, PartialEq)]
-pub struct BlockV10Parameters {
-    /// UD target growth rate (see Relative Theorie of Money)
-    pub c: f64,
-    /// Duration between the creation of two UD (in seconds)
-    pub dt: u64,
-    /// Amount of the initial UD
-    pub ud0: usize,
-    /// Minimum duration between the writing of 2 certifications from the same issuer (in seconds)
-    pub sig_period: u64,
-    /// Maximum number of active certifications at the same time (for the same issuer)
-    pub sig_stock: usize,
-    /// Maximum retention period of a pending certification
-    pub sig_window: u64,
-    /// Time to expiry of written certification
-    pub sig_validity: u64,
-    /// Minimum number of certifications required to become a member
-    pub sig_qty: usize,
-    /// Maximum retention period of a pending identity
-    pub idty_window: u64,
-    /// Maximum retention period of a pending membership
-    pub ms_window: u64,
-    /// Percentage of referring members who must be within step_max steps of each member
-    pub x_percent: f64,
-    /// Time to expiry of written membership
-    pub ms_validity: u64,
-    /// For a member to respect the distance rule,
-    /// there must exist for more than x_percent % of the referring members
-    /// a path of less than step_max steps from the referring member to the evaluated member.
-    pub step_max: usize,
-    /// Number of blocks used for calculating median time.
-    pub median_time_blocks: usize,
-    /// The average time for writing 1 block (wished time)
-    pub avg_gen_time: u64,
-    /// The number of blocks required to evaluate again PoWMin value
-    pub dt_diff_eval: usize,
-    /// The percent of previous issuers to reach for personalized difficulty
-    pub percent_rot: f64,
-    /// Time of first UD.
-    pub ud_time0: u64,
-    /// Time of first reevaluation of the UD.
-    pub ud_reeval_time0: u64,
-    /// Time period between two re-evaluation of the UD.
-    pub dt_reeval: u64,
-}
-
-impl Default for BlockV10Parameters {
-    fn default() -> BlockV10Parameters {
-        BlockV10Parameters {
-            c: 0.0488,
-            dt: 86_400,
-            ud0: 1_000,
-            sig_period: 432_000,
-            sig_stock: 100,
-            sig_window: 5_259_600,
-            sig_validity: 63_115_200,
-            sig_qty: 5,
-            idty_window: 5_259_600,
-            ms_window: 5_259_600,
-            x_percent: 0.8,
-            ms_validity: 31_557_600,
-            step_max: 5,
-            median_time_blocks: 24,
-            avg_gen_time: 300,
-            dt_diff_eval: 12,
-            percent_rot: 0.67,
-            ud_time0: 1_488_970_800,
-            ud_reeval_time0: 1_490_094_000,
-            dt_reeval: 15_778_800,
-        }
-    }
-}
-
-impl ::std::str::FromStr for BlockV10Parameters {
-    type Err = ParseParamsError;
-
-    fn from_str(source: &str) -> Result<Self, Self::Err> {
-        let params: Vec<&str> = source.split(':').collect();
-        Ok(BlockV10Parameters {
-            c: params[0].parse()?,
-            dt: params[1].parse()?,
-            ud0: params[2].parse()?,
-            sig_period: params[3].parse()?,
-            sig_stock: params[4].parse()?,
-            sig_window: params[5].parse()?,
-            sig_validity: params[6].parse()?,
-            sig_qty: params[7].parse()?,
-            idty_window: params[8].parse()?,
-            ms_window: params[9].parse()?,
-            x_percent: params[10].parse()?,
-            ms_validity: params[11].parse()?,
-            step_max: params[12].parse()?,
-            median_time_blocks: params[13].parse()?,
-            avg_gen_time: params[14].parse()?,
-            dt_diff_eval: params[15].parse()?,
-            percent_rot: params[16].parse()?,
-            ud_time0: params[17].parse()?,
-            ud_reeval_time0: params[18].parse()?,
-            dt_reeval: params[19].parse()?,
-        })
-    }
-}
-
-impl ToString for BlockV10Parameters {
-    fn to_string(&self) -> String {
-        format!(
-            "{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}",
-            self.c,
-            self.dt,
-            self.ud0,
-            self.sig_period,
-            self.sig_stock,
-            self.sig_window,
-            self.sig_validity,
-            self.sig_qty,
-            self.idty_window,
-            self.ms_window,
-            self.x_percent,
-            self.ms_validity,
-            self.step_max,
-            self.median_time_blocks,
-            self.avg_gen_time,
-            self.dt_diff_eval,
-            self.percent_rot,
-            self.ud_time0,
-            self.ud_reeval_time0,
-            self.dt_reeval,
-        )
-    }
-}
-
-impl Eq for BlockV10Parameters {}
-
 /// Store a transaction document or just its hash.
 #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
 pub enum TxDocOrTxHash {
diff --git a/lib/tools/documents/src/lib.rs b/lib/tools/documents/src/lib.rs
index 940b8841..2f805603 100644
--- a/lib/tools/documents/src/lib.rs
+++ b/lib/tools/documents/src/lib.rs
@@ -38,13 +38,10 @@ extern crate pretty_assertions;
 extern crate serde_derive;
 
 pub mod blockstamp;
-mod currencies_codes;
 pub mod documents;
 pub mod parsers;
 pub mod text_document_traits;
 
-use crate::currencies_codes::*;
-use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
 use dup_crypto::hashs::Hash;
 use dup_crypto::keys::*;
 use pest::iterators::Pair;
@@ -52,8 +49,6 @@ use pest::RuleType;
 use serde::Serialize;
 use std::cmp::Ordering;
 use std::fmt::{Debug, Display, Error, Formatter};
-use std::io::Cursor;
-use std::mem;
 
 pub use crate::blockstamp::{Blockstamp, PreviousBlockstamp};
 
@@ -89,71 +84,6 @@ pub enum TextDocumentParseError {
     UnknownType,
 }
 
-/// Currency name
-#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize, Hash)]
-pub struct CurrencyName(pub String);
-
-impl Default for CurrencyName {
-    fn default() -> CurrencyName {
-        CurrencyName(String::from("default_currency"))
-    }
-}
-
-impl Display for CurrencyName {
-    fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
-        write!(f, "{}", self.0)
-    }
-}
-
-/// CurrencyCodeError
-#[derive(Debug)]
-pub enum CurrencyCodeError {
-    /// UnknowCurrencyCode
-    UnknowCurrencyCode(),
-    /// IoError
-    IoError(::std::io::Error),
-    /// UnknowCurrencyName
-    UnknowCurrencyName(),
-}
-
-impl From<::std::io::Error> for CurrencyCodeError {
-    fn from(error: ::std::io::Error) -> Self {
-        CurrencyCodeError::IoError(error)
-    }
-}
-
-impl CurrencyName {
-    /// Convert bytes to CurrencyName
-    pub fn from(currency_code: [u8; 2]) -> Result<Self, CurrencyCodeError> {
-        let mut currency_code_bytes = Cursor::new(currency_code.to_vec());
-        let currency_code = currency_code_bytes.read_u16::<BigEndian>()?;
-        Self::from_u16(currency_code)
-    }
-    /// Convert u16 to CurrencyName
-    pub fn from_u16(currency_code: u16) -> Result<Self, CurrencyCodeError> {
-        match currency_code {
-            tmp if tmp == *CURRENCY_NULL => Ok(CurrencyName(String::from(""))),
-            tmp if tmp == *CURRENCY_G1 => Ok(CurrencyName(String::from("g1"))),
-            tmp if tmp == *CURRENCY_G1_TEST => Ok(CurrencyName(String::from("g1-test"))),
-            _ => Err(CurrencyCodeError::UnknowCurrencyCode()),
-        }
-    }
-    /// Convert CurrencyName to bytes
-    pub fn to_bytes(&self) -> Result<[u8; 2], CurrencyCodeError> {
-        let currency_code = match self.0.as_str() {
-            "g1" => *CURRENCY_G1,
-            "g1-test" => *CURRENCY_G1_TEST,
-            _ => return Err(CurrencyCodeError::UnknowCurrencyName()),
-        };
-        let mut buffer = [0u8; mem::size_of::<u16>()];
-        buffer
-            .as_mut()
-            .write_u16::<BigEndian>(currency_code)
-            .expect("Unable to write");
-        Ok(buffer)
-    }
-}
-
 /// A block Id.
 #[derive(Copy, Clone, Debug, Deserialize, Ord, PartialEq, PartialOrd, Eq, Hash, Serialize)]
 pub struct BlockNumber(pub u32);
diff --git a/lib/tools/documents/src/parsers/blocks.rs b/lib/tools/documents/src/parsers/blocks.rs
index 2153e2bb..fb0c275b 100644
--- a/lib/tools/documents/src/parsers/blocks.rs
+++ b/lib/tools/documents/src/parsers/blocks.rs
@@ -13,13 +13,15 @@
 // You should have received a copy of the GNU Affero General Public License
 // along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-use crate::documents::block::{BlockDocument, BlockV10Parameters, TxDocOrTxHash};
+use crate::documents::block::{BlockDocument, TxDocOrTxHash};
 use crate::documents::membership::MembershipType;
 use crate::parsers::DefaultHasher;
 use crate::*;
 use dup_crypto::bases::BaseConvertionError;
 use dup_crypto::hashs::Hash;
 use dup_crypto::keys::*;
+use dup_currency_params::genesis_block_params::v10::BlockV10Parameters;
+use dup_currency_params::CurrencyName;
 use failure::Error;
 use json_pest_parser::*;
 use std::str::FromStr;
diff --git a/lib/tools/network-documents/Cargo.toml b/lib/tools/network-documents/Cargo.toml
index ea1047e0..6dca76c5 100644
--- a/lib/tools/network-documents/Cargo.toml
+++ b/lib/tools/network-documents/Cargo.toml
@@ -16,6 +16,7 @@ log = "0.4.*"
 durs-common-tools = { path = "../common-tools" }
 base58 = "0.1.*"
 dup-crypto = { path = "../crypto" }
+dup-currency-params = { path = "../../tools/currency-params" }
 dubp-documents= { path = "../documents" }
 hex = "0.3.*"
 pest = "2.1.0"
diff --git a/lib/tools/network-documents/src/network_head_v3.rs b/lib/tools/network-documents/src/network_head_v3.rs
index 22e9849b..edc69c51 100644
--- a/lib/tools/network-documents/src/network_head_v3.rs
+++ b/lib/tools/network-documents/src/network_head_v3.rs
@@ -18,9 +18,10 @@
 use crate::*;
 use base58::ToBase58;
 use dubp_documents::blockstamp::Blockstamp;
-use dubp_documents::{BlockHash, BlockNumber, CurrencyName, ToStringObject};
+use dubp_documents::{BlockHash, BlockNumber, ToStringObject};
 use dup_crypto::keys::text_signable::TextSignable;
 use dup_crypto::keys::*;
+use dup_currency_params::CurrencyName;
 use pest::iterators::Pair;
 use pest::Parser;
 use std::cmp::Ordering;
diff --git a/lib/tools/network-documents/src/network_peer.rs b/lib/tools/network-documents/src/network_peer.rs
index 148498e3..8c1f947a 100644
--- a/lib/tools/network-documents/src/network_peer.rs
+++ b/lib/tools/network-documents/src/network_peer.rs
@@ -18,11 +18,12 @@
 use crate::network_endpoint::*;
 use crate::*;
 use base58::ToBase58;
+use dubp_documents::blockstamp::Blockstamp;
 use dubp_documents::ToStringObject;
-use dubp_documents::{blockstamp::Blockstamp, CurrencyName};
 use dubp_documents::{BlockHash, BlockNumber};
 use dup_crypto::keys::text_signable::TextSignable;
 use dup_crypto::keys::*;
+use dup_currency_params::CurrencyName;
 use pest::iterators::Pair;
 use pest::Parser;
 
-- 
GitLab