Commit 68d106e4 authored by Éloïs's avatar Éloïs

[ref] module: rename trait DuniterModule -> DursModule

parent c4aecd01
......@@ -215,7 +215,7 @@ impl<'a, 'b: 'a> DuniterCore<'b, 'a, DuRsConf> {
}
}
/// Inject cli subcommand
pub fn inject_cli_subcommand<M: DuniterModule<DuRsConf, DursMsg>>(&mut self) {
pub fn inject_cli_subcommand<M: DursModule<DuRsConf, DursMsg>>(&mut self) {
if M::have_subcommand() {
self.plugins_cli_conf.push(M::ModuleOpt::clap());
}
......@@ -310,11 +310,7 @@ impl<'a, 'b: 'a> DuniterCore<'b, 'a, DuRsConf> {
match opts.source_type {
SyncSourceType::Network => unimplemented!(),
SyncSourceType::TsSqlDb => {
sync_ts(
profile.as_str(),
&conf,
&opts
);
sync_ts(profile.as_str(), &conf, &opts);
}
SyncSourceType::JsonFiles => unimplemented!(),
}
......@@ -544,12 +540,12 @@ impl<'a, 'b: 'a> DuniterCore<'b, 'a, DuRsConf> {
}
/// Plug a module
pub fn plug<M: DuniterModule<DuRsConf, DursMsg>>(&mut self) {
pub fn plug<M: DursModule<DuRsConf, DursMsg>>(&mut self) {
self.plug_::<M>(false);
}
/// Plug a module
pub fn plug_<M: DuniterModule<DuRsConf, DursMsg>>(&mut self, is_network_module: bool) {
pub fn plug_<M: DursModule<DuRsConf, DursMsg>>(&mut self, is_network_module: bool) {
let enabled = enabled::<DuRsConf, DursMsg, M>(&self.soft_meta_datas.conf);
if enabled {
if let Some(UserCommand::Start()) = self.user_command {
......@@ -638,7 +634,7 @@ impl<'a, 'b: 'a> DuniterCore<'b, 'a, DuRsConf> {
}
/// Get module conf and keys
pub fn get_module_conf_and_keys<M: DuniterModule<DuRsConf, DursMsg>>(
pub fn get_module_conf_and_keys<M: DursModule<DuRsConf, DursMsg>>(
module_conf_json: Option<serde_json::Value>,
keypairs: DuniterKeyPairs,
) -> (M::ModuleConf, RequiredKeysContent) {
......@@ -649,7 +645,7 @@ pub fn get_module_conf_and_keys<M: DuniterModule<DuRsConf, DursMsg>>(
}
/// get module conf
pub fn get_module_conf<M: DuniterModule<DuRsConf, DursMsg>>(
pub fn get_module_conf<M: DursModule<DuRsConf, DursMsg>>(
module_conf_json: Option<serde_json::Value>,
) -> M::ModuleConf {
if let Some(module_conf_json) = module_conf_json {
......@@ -666,11 +662,7 @@ pub fn match_profile(cli_args: &ArgMatches) -> String {
}
/// Launch synchronisation from a duniter-ts database
pub fn sync_ts<DC: DuniterConf>(
profile: &str,
conf: &DC,
sync_opts: &SyncOpt,
) {
pub fn sync_ts<DC: DuniterConf>(profile: &str, conf: &DC, sync_opts: &SyncOpt) {
// Launch sync-ts
BlockchainModule::sync_ts(profile, conf, sync_opts);
}
......
......@@ -14,7 +14,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! Defined the few global types used by all modules,
//! as well as the DuniterModule trait that all modules must implement.
//! as well as the DursModule trait that all modules must implement.
#![cfg_attr(feature = "strict", deny(warnings))]
#![deny(
......@@ -274,9 +274,7 @@ pub enum ModulePriority {
}
/// Determines if a module is activated or not
pub fn enabled<DC: DuniterConf, Mess: ModuleMessage, M: DuniterModule<DC, Mess>>(
conf: &DC,
) -> bool {
pub fn enabled<DC: DuniterConf, Mess: ModuleMessage, M: DursModule<DC, Mess>>(conf: &DC) -> bool {
let disabled_modules = conf.disabled_modules();
let enabled_modules = conf.enabled_modules();
match M::priority() {
......@@ -302,7 +300,7 @@ pub enum ModulesFilter {
pub fn module_valid_filters<
DC: DuniterConf,
Mess: ModuleMessage,
M: DuniterModule<DC, Mess>,
M: DursModule<DC, Mess>,
S: ::std::hash::BuildHasher,
>(
conf: &DC,
......@@ -327,7 +325,7 @@ pub fn module_valid_filters<
}
/// All Duniter-rs modules must implement this trait.
pub trait DuniterModule<DC: DuniterConf, M: ModuleMessage> {
pub trait DursModule<DC: DuniterConf, M: ModuleMessage> {
/// Module configuration
type ModuleConf: Clone + Debug + Default + DeserializeOwned + Send + Serialize + Sync;
/// Module subcommand options
......
......@@ -51,7 +51,7 @@ pub mod events;
pub mod requests;
/// ApiModule
pub trait ApiModule<DC: DuniterConf, M: ModuleMessage>: DuniterModule<DC, M> {
pub trait ApiModule<DC: DuniterConf, M: ModuleMessage>: DursModule<DC, M> {
/// Parsing error
type ParseErr;
/// Parse raw api features
......@@ -64,7 +64,7 @@ pub trait NetworkModule<DC: DuniterConf, M: ModuleMessage>: ApiModule<DC, M> {
fn sync(
soft_meta_datas: &SoftwareMetaDatas<DC>,
keys: RequiredKeysContent,
module_conf: <Self as DuniterModule<DC, M>>::ModuleConf,
module_conf: <Self as DursModule<DC, M>>::ModuleConf,
main_sender: mpsc::Sender<RouterThreadMessage<M>>,
sync_params: SyncOpt,
) -> Result<(), ModuleInitError>;
......
......@@ -207,11 +207,7 @@ impl BlockchainModule {
dbex::dbex(profile, conf, csv, req);
}
/// Synchronize blockchain from a duniter-ts database
pub fn sync_ts<DC: DuniterConf>(
profile: &str,
conf: &DC,
sync_opts: &SyncOpt,
) {
pub fn sync_ts<DC: DuniterConf>(profile: &str, conf: &DC, sync_opts: &SyncOpt) {
// get db_ts_path
let db_ts_path = if let Some(ref ts_path) = sync_opts.source {
PathBuf::from(ts_path)
......@@ -228,7 +224,14 @@ impl BlockchainModule {
if !db_ts_path.as_path().exists() {
panic!("Fatal error : duniter-ts database don't exist !");
}
sync::sync_ts(profile, conf, db_ts_path, sync_opts.end, sync_opts.cautious_mode, !sync_opts.unsafe_mode);
sync::sync_ts(
profile,
conf,
db_ts_path,
sync_opts.end,
sync_opts.cautious_mode,
!sync_opts.unsafe_mode,
);
}
/// Request chunk from network (chunk = group of blocks)
fn request_chunk(&self, req_id: ModuleReqId, from: u32) -> (ModuleReqId, OldNetworkRequest) {
......
......@@ -664,7 +664,7 @@ pub fn sync_ts<DC: DuniterConf>(
let mut wait_jobs = *NB_SYNC_JOBS - 1;
while wait_jobs > 0 {
match recv_sync_thread.recv() {
Ok(MessForSyncThread::ApplyFinish()) => wait_jobs -= 1,
Ok(MessForSyncThread::ApplyFinish()) => wait_jobs -= 1,
Ok(_) => thread::sleep(Duration::from_millis(50)),
Err(_) => wait_jobs -= 1,
}
......
......@@ -113,7 +113,7 @@ impl Default for SkeletonModule {
}
}
impl DuniterModule<DuRsConf, DursMsg> for SkeletonModule {
impl DursModule<DuRsConf, DursMsg> for SkeletonModule {
type ModuleConf = SkeletonConf;
type ModuleOpt = SkeletonOpt;
......
......@@ -14,7 +14,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! Defined the few global types used by all modules,
//! as well as the DuniterModule trait that all modules must implement.
//! as well as the DursModule trait that all modules must implement.
#![cfg_attr(feature = "strict", deny(warnings))]
#![deny(
......@@ -388,7 +388,7 @@ impl Default for TuiModule {
}
}
impl DuniterModule<DuRsConf, DursMsg> for TuiModule {
impl DursModule<DuRsConf, DursMsg> for TuiModule {
type ModuleConf = TuiConf;
type ModuleOpt = TuiOpt;
......
......@@ -246,7 +246,7 @@ impl NetworkModule<DuRsConf, DursMsg> for WS2PModule {
/// WS2Pv1 subcommand options
pub struct WS2POpt {}
impl DuniterModule<DuRsConf, DursMsg> for WS2PModule {
impl DursModule<DuRsConf, DursMsg> for WS2PModule {
type ModuleConf = WS2PConf;
type ModuleOpt = WS2POpt;
......@@ -953,7 +953,7 @@ mod tests {
use super::parsers::blocks::parse_json_block;
use super::*;
use dubp_documents::v10::BlockDocument;
use duniter_module::DuniterModule;
use duniter_module::DursModule;
use duniter_network::documents::NetworkBlock;
use dup_crypto::keys::PublicKey;
use durs_network_documents::network_endpoint::NetworkEndpointApi;
......
......@@ -141,7 +141,7 @@ impl NetworkModule<DuRsConf, DursMsg> for WS2Pv2Module {
/// WS2P subcommand options
pub struct WS2POpt {}
impl DuniterModule<DuRsConf, DursMsg> for WS2Pv2Module {
impl DursModule<DuRsConf, DursMsg> for WS2Pv2Module {
type ModuleConf = WS2PConf;
type ModuleOpt = WS2POpt;
......
......@@ -142,7 +142,7 @@ impl NetworkModule<DuRsConf, DursMsg> for WS2Pv2Module {
/// WS2P subcommand options
pub struct WS2POpt {}
impl DuniterModule<DuRsConf, DursMsg> for WS2Pv2Module {
impl DursModule<DuRsConf, DursMsg> for WS2Pv2Module {
type ModuleConf = WS2PConf;
type ModuleOpt = WS2POpt;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment