From 0e8e47234f5a85655477b9e6ff9832ff04e6b395 Mon Sep 17 00:00:00 2001
From: librelois <elois@ifee.fr>
Date: Sat, 23 Jun 2018 00:46:16 +0200
Subject: [PATCH] [ref] remove old commented code

---
 blockchain/lib.rs |  9 +-----
 conf/lib.rs       | 38 ------------------------
 documents/lib.rs  | 76 -----------------------------------------------
 module/lib.rs     | 22 --------------
 tui/lib.rs        |  3 --
 ws2p/datas.rs     | 62 --------------------------------------
 ws2p/lib.rs       | 69 ++----------------------------------------
 7 files changed, 3 insertions(+), 276 deletions(-)

diff --git a/blockchain/lib.rs b/blockchain/lib.rs
index 7cbacc05..af554407 100644
--- a/blockchain/lib.rs
+++ b/blockchain/lib.rs
@@ -807,14 +807,7 @@ impl BlockchainModule {
                     current_blockstamp
                 );
             }
-            // Apply wot events
-            /*BlockchainModule::apply_wot_events(
-                &wot_events,
-                &wot_path,
-                &current_blockstamp,
-                &mut wot,
-                &mut wotb_index,
-            );*/        }
+        }
     }
 }
 
diff --git a/conf/lib.rs b/conf/lib.rs
index 41a5c169..a19b649f 100644
--- a/conf/lib.rs
+++ b/conf/lib.rs
@@ -337,28 +337,6 @@ pub fn load_conf_at_path(profile: &str, profile_path: &PathBuf) -> (DuRsConf, Du
             let mut contents = String::new();
             if f.read_to_string(&mut contents).is_ok() {
                 conf = serde_json::from_str(&contents).expect("Conf: Fail to parse conf file !");
-                /*let json_conf: serde_json::Value =
-                    serde_json::from_str(&contents).expect("Conf: Fail to parse conf file !");
-                if let Some(currency) = json_conf.get("currency") {
-                    conf.currency = Currency::Str(
-                        currency
-                            .as_str()
-                            .expect("Conf: fail to parse currency field !")
-                            .to_string(),
-                    );
-                };
-                if let Some(node_id) = json_conf.get("node_id") {
-                    conf.my_node_id =
-                        u32::from_str_radix(
-                            node_id
-                                .as_str()
-                                .expect("Conf : fail to parse node_id field !"),
-                            16,
-                        ).expect("Fail to load conf: node_id must be an hexadecimal number !");
-                };
-                if let Some(modules_conf) = json_conf.get("modules") {
-                    conf.modules = modules_conf.clone();
-                };*/
             }
         } else {
             panic!("Fail to open conf file !");
@@ -400,22 +378,6 @@ pub fn write_conf_file<DC: DuniterConf>(profile: &str, conf: &DC) -> Result<(),
             .as_bytes(),
     )?;
     f.sync_all()?;
-    /*match *conf {
-        DuRsConf::V1(ref conf_v1) => {
-            let mut f = try!(File::create(conf_path.as_path()));
-            try!(
-                f.write_all(
-                    serde_json::to_string_pretty(conf_v1)
-                        .expect("Fatal error : fail to write default conf file !")
-                        .as_bytes()
-                )
-            );
-            try!(f.sync_all());
-        }
-        _ => {
-            panic!("Fatal error : Conf version is not supported !");
-        }
-    }*/
     Ok(())
 }
 
diff --git a/documents/lib.rs b/documents/lib.rs
index 4d006cb6..1ea99142 100644
--- a/documents/lib.rs
+++ b/documents/lib.rs
@@ -194,82 +194,6 @@ impl Default for Blockstamp {
     }
 }
 
-/*impl Serialize for Blockstamp {
-    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
-    where
-        S: Serializer,
-    {
-        serializer.serialize_str(&format!("{}-{}", self.id, self.hash))
-    }
-}*/
-
-/*impl<'de> Deserialize<'de> for Blockstamp {
-    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
-    where
-        D: Deserializer<'de>,
-    {
-        #[derive(Deserialize)]
-        #[serde(field_identifier, rename_all = "lowercase")]
-        enum Field {
-            Id,
-            Hash,
-        }
-
-        struct BlockstampVisitor;
-
-        impl<'de> Visitor<'de> for BlockstampVisitor {
-            type Value = Blockstamp;
-
-            fn expecting(&self, formatter: &mut Formatter) -> fmt::Result {
-                formatter.write_str("struct Blockstamp")
-            }
-
-            fn visit_seq<V>(self, mut seq: V) -> Result<Blockstamp, V::Error>
-            where
-                V: SeqAccess<'de>,
-            {
-                let id = seq
-                    .next_element()?
-                    .ok_or_else(|| de::Error::invalid_length(0, &self))?;
-                let hash = seq
-                    .next_element()?
-                    .ok_or_else(|| de::Error::invalid_length(1, &self))?;
-                Ok(Blockstamp { id, hash })
-            }
-
-            fn visit_map<V>(self, mut map: V) -> Result<Blockstamp, V::Error>
-            where
-                V: MapAccess<'de>,
-            {
-                let mut id = None;
-                let mut hash = None;
-                while let Some(key) = map.next_key()? {
-                    match key {
-                        Field::Id => {
-                            if id.is_some() {
-                                return Err(de::Error::duplicate_field("id"));
-                            }
-                            id = Some(map.next_value()?);
-                        }
-                        Field::Hash => {
-                            if hash.is_some() {
-                                return Err(de::Error::duplicate_field("hash"));
-                            }
-                            hash = Some(map.next_value()?);
-                        }
-                    }
-                }
-                let id = id.ok_or_else(|| de::Error::missing_field("id"))?;
-                let hash = hash.ok_or_else(|| de::Error::missing_field("hash"))?;
-                Ok(Blockstamp { id, hash })
-            }
-        }
-
-        const FIELDS: &'static [&'static str] = &["id", "hash"];
-        deserializer.deserialize_struct("Blockstamp", FIELDS, BlockstampVisitor)
-    }
-}*/
-
 impl PartialOrd for Blockstamp {
     fn partial_cmp(&self, other: &Blockstamp) -> Option<Ordering> {
         Some(self.cmp(other))
diff --git a/module/lib.rs b/module/lib.rs
index a24fa718..3c5636c9 100644
--- a/module/lib.rs
+++ b/module/lib.rs
@@ -64,19 +64,6 @@ impl ToString for ModuleId {
     }
 }
 
-/*impl Serialize for ModuleId {
-    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
-    where
-        S: Serializer,
-    {
-        let module_id_string = match *self {
-            ModuleId::Str(module_id_str) => String::from(module_id_str),
-            ModuleId::Bin(_) => panic!("ModuleId binary format is not implemented !"),
-        };
-        serializer.serialize_str(module_id_string.as_str())
-    }
-}*/
-
 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
 /// Identifier of an inter-module request
 pub struct ModuleReqId(pub u32);
@@ -101,15 +88,6 @@ impl ToString for ModuleReqFullId {
     }
 }
 
-/*impl Serialize for ModuleReqFullId {
-    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
-    where
-        S: Serializer,
-    {
-        serializer.serialize_str(&format!("{}-{}",  self.0.to_string(), (self.1).0))
-    }
-}*/
-
 /// Duniter configuration
 pub trait DuniterConf: Clone + Debug + Default + PartialEq + Serialize + DeserializeOwned {
     /// Get conf version profile
diff --git a/tui/lib.rs b/tui/lib.rs
index 3c3c763e..29e0013d 100644
--- a/tui/lib.rs
+++ b/tui/lib.rs
@@ -322,9 +322,6 @@ impl TuiModuleDatas {
             "{:02}:{:02}:{:02}",
             runtime_hours, runtime_mins, runtime_secs
         );
-        /*DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp(runtime_in_secs, 0), Utc)
-                .format("%H:%M:%S")
-                .to_string();*/
         write!(
             stdout,
             "{}{}{}runtime : {}",
diff --git a/ws2p/datas.rs b/ws2p/datas.rs
index 0bb0da47..0177cf12 100644
--- a/ws2p/datas.rs
+++ b/ws2p/datas.rs
@@ -58,68 +58,6 @@ impl WS2PModuleDatas {
         }
         Ok(conn)
     }
-    /*pub fn parse_ws2p_conf(
-        duniter_conf: &DuRsConf,
-        ws2p_json_conf: &serde_json::Value,
-    ) -> WS2PConf {
-        let mut sync_endpoints = Vec::new();
-        match ws2p_json_conf.get("sync_peers") {
-            Some(peers) => {
-                let array_peers = peers.as_array().expect("Conf: Fail to parse conf file !");
-                for peer in array_peers {
-                    let pubkey = match peer.get("pubkey") {
-                        Some(pubkey) => PubKey::Ed25519(
-                            ed25519::PublicKey::from_base58(
-                                pubkey
-                                    .as_str()
-                                    .expect("WS2PConf Error : fail to parse sync endpoint pubkey"),
-                            ).expect("WS2PConf Error : fail to parse sync endpoint pubkey"),
-                        ),
-                        None => panic!(
-                            "Fail to load ws2p conf : \
-                             WrongFormat : not found pubkey field !"
-                        ),
-                    };
-                    match peer.get("ws2p_endpoints") {
-                        Some(endpoints) => {
-                            let array_endpoints = endpoints
-                                .as_array()
-                                .expect("Conf: Fail to parse conf file !");
-                            for endpoint in array_endpoints {
-                                sync_endpoints.push(
-                                    NetworkEndpoint::parse_from_raw(
-                                        endpoint.as_str().expect("WS2P: Fail to get ep.as_str() !"),
-                                        pubkey,
-                                        0,
-                                        0,
-                                    ).unwrap_or_else(|| {
-                                        panic!(
-                                            "WS2PConf Error : fail to parse sync Endpoint = {:?}",
-                                            endpoint
-                                                .as_str()
-                                                .expect("WS2P: Fail to get ep.as_str() !")
-                                        )
-                                    }),
-                                );
-                            }
-                        }
-                        None => panic!(
-                            "Fail to load conf : \
-                             WrongFormat : not found ws2p_endpoints field !"
-                        ),
-                    };
-                }
-            }
-            None => panic!(
-                "Configuration Error : \
-                 You must declare at least one node on which to synchronize !"
-            ),
-        };
-        WS2PConf {
-            outcoming_quota: *WS2P_DEFAULT_OUTCOMING_QUOTA,
-            sync_endpoints,
-        }
-    }*/
     pub fn send_dal_request(&self, req: &DALRequest) {
         for follower in &self.followers {
             if follower
diff --git a/ws2p/lib.rs b/ws2p/lib.rs
index faa338b6..87ccffe6 100644
--- a/ws2p/lib.rs
+++ b/ws2p/lib.rs
@@ -201,17 +201,6 @@ impl DuniterModule<DuRsConf, DuniterMessage> for WS2PModule {
     fn ask_required_keys() -> RequiredKeys {
         RequiredKeys::NetworkKeyPair()
     }
-    /*fn default_conf() -> serde_json::Value {
-        json!({
-            "sync_peers": [{
-                "pubkey": "D9D2zaJoWYWveii1JRYLVK3J4Z7ZH3QczoKrnQeiM6mx",
-                "ws2p_endpoints": ["WS2P c1c39a0a i3.ifee.fr 80 /ws2p"]
-            },{
-                "pubkey": "7v2J4badvfWQ6qwRdCwhhJfAsmKwoxRUNpJHiJHj7zef",
-                "ws2p_endpoints": ["WS2P b48824f0 g1.monnaielibreoccitanie.org 80 /ws2p"]
-            }]
-        })
-    }*/
     fn start(
         soft_meta_datas: &SoftwareMetaDatas<DuRsConf>,
         keys: RequiredKeysContent,
@@ -742,65 +731,11 @@ impl DuniterModule<DuRsConf, DuniterMessage> for WS2PModule {
             {
                 last_ws2p_connections_print = SystemTime::now();
                 let mut connected_nodes = Vec::new();
-                let mut denial_nodes = Vec::new();
-                let mut disconnected_nodes = Vec::new();
-                let mut unreachable_nodes = Vec::new();
-                let mut ws_error_nodes = Vec::new();
                 for (k, (_ep, state)) in ws2p_module.ws2p_endpoints.clone() {
-                    match state {
-                        WS2PConnectionState::NeverTry => {
-                            //writeln!("Never try : {}", k);
-                        }
-                        WS2PConnectionState::TryToOpenWS => {}//writeln!("TryToOpenWS : {}", k),
-                        WS2PConnectionState::WSError => {
-                            ws_error_nodes.push(k);
-                        }
-                        WS2PConnectionState::TryToSendConnectMess => {
-                            //writeln!("TryToSendConnectMess : {}", k)
-                        }
-                        WS2PConnectionState::Unreachable => {
-                            unreachable_nodes.push(k);
-                        }
-                        WS2PConnectionState::WaitingConnectMess => {
-                            //writeln!("WaitingConnectMess : {}", k)
-                        }
-                        WS2PConnectionState::NoResponse => {}//writeln!("NoResponse : {}", k),
-                        WS2PConnectionState::AckMessOk
-                        | WS2PConnectionState::ConnectMessOk
-                        | WS2PConnectionState::OkMessOkWaitingAckMess => {
-                            //writeln!("Ongoing negotiations : {}", k)
-                        }
-                        WS2PConnectionState::Denial => {
-                            denial_nodes.push(k);
-                        }
-                        WS2PConnectionState::Established => {
-                            connected_nodes.push(k);
-                        }
-                        WS2PConnectionState::Close => {
-                            disconnected_nodes.push(k);
-                        }
+                    if let WS2PConnectionState::Established = state {
+                        connected_nodes.push(k);
                     }
                 }
-                /*writeln!(
-                                    "Connected with {} nodes. (Denial : {}, Disconnected : {}, Unreachable: {}, WSError : {})",
-                                    connected_nodes.len(),
-                                    denial_nodes.len(),
-                                    disconnected_nodes.len(),
-                                    unreachable_nodes.len(),
-                                    ws_error_nodes.len()
-                                );*/
-                for _node in connected_nodes.clone() {
-                    //writeln!("Connection established : {}", node);
-                }
-                for _node in denial_nodes {
-                    //writeln!("Denial : {}", node);
-                }
-                for _node in disconnected_nodes {
-                    //writeln!("Disconnected : {}", node);
-                }
-                for _node in unreachable_nodes {
-                    //writeln!("Unreachable : {}", node);
-                }
                 // Print network consensus
                 match ws2p_module.get_network_consensus() {
                     Ok(consensus_blockstamp) => {
-- 
GitLab