From 1bf371531d0e147763b6a7eb824d87357acd0181 Mon Sep 17 00:00:00 2001
From: Hugo Trentesaux <hugo@trentesaux.fr>
Date: Sat, 23 Nov 2019 11:50:03 +0100
Subject: [PATCH] wip mini clean

---
 Cargo.lock                                      |  6 +++---
 lib/modules/ws2p/ws2p-protocol/src/websocket.rs | 14 +-------------
 lib/modules/ws2p/ws2p/src/websocket.rs          |  3 +++
 lib/modules/ws2p/ws2p/tests/syncronisation.rs   |  2 +-
 4 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index f1501134..04f09355 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1214,6 +1214,7 @@ dependencies = [
  "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
  "structopt 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "ws 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -1222,7 +1223,6 @@ name = "durs-ws2p-messages"
 version = "0.3.0-dev"
 dependencies = [
  "bincode 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "dubp-block-doc 0.1.0",
  "dubp-common-doc 0.1.0",
  "dubp-currency-params 0.2.0",
@@ -1235,7 +1235,6 @@ dependencies = [
  "pkstl 0.1.0",
  "pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -1261,6 +1260,7 @@ dependencies = [
  "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "pkstl 0.1.0",
  "pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
  "unwrap 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2245,7 +2245,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
  "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
diff --git a/lib/modules/ws2p/ws2p-protocol/src/websocket.rs b/lib/modules/ws2p/ws2p-protocol/src/websocket.rs
index d61c56f9..c15ade15 100644
--- a/lib/modules/ws2p/ws2p-protocol/src/websocket.rs
+++ b/lib/modules/ws2p/ws2p-protocol/src/websocket.rs
@@ -106,6 +106,7 @@ pub enum WsError {
 
 /// the websocket trait is an abstraction allowing to move the logic of websocket handling
 /// in the protocol crate
+/// it has a listen and exec function (not sure if it should have a connect function)
 pub trait WebsocketTrait: Debug + Clone + Send {
     /// constructor
     fn new(
@@ -129,16 +130,3 @@ pub trait WebsocketTrait: Debug + Clone + Send {
     /// Execute websocket action without precising success or failure states
     fn exec(&self, action: WebsocketAction) -> Result<(), WsError>;
 }
-
-// je n'ai pas bien compris la différence entre WebsocketAction et WebsocketActionOrder
-// donc j'ai fait deux fonctions exec de manière temporaire pour transformer l'un en l'autre
-
-// fn exec_action(&self, action: WebsocketAction) -> Result<(), WsError> {
-//     /// transform Action into ActionOrder
-//     let action_order = WebsocketActionOrder {
-//         ws_action: action,
-//         new_state_if_success: None,
-//         new_state_if_fail: WS2PConnectionState::Close,
-//     };
-//     self.exec(action_order)
-// }
diff --git a/lib/modules/ws2p/ws2p/src/websocket.rs b/lib/modules/ws2p/ws2p/src/websocket.rs
index 77e135c2..c43d6ff0 100644
--- a/lib/modules/ws2p/ws2p/src/websocket.rs
+++ b/lib/modules/ws2p/ws2p/src/websocket.rs
@@ -33,6 +33,9 @@ use std::net::ToSocketAddrs;
 use std::sync::mpsc;
 
 #[derive(Debug, Clone)]
+/// the WebsocketConnector is just a small structure containing minimal information
+/// that will implement the WebsocketTrait
+/// it will allow the ws2p-protocol crate to manage websocket-specific actions like opening connection...
 pub struct WebsocketConnector {
     my_self_ws2p_node: MySelfWs2pNode,
     orchestrator_sender: mpsc::Sender<OrchestratorMsg<DursMsg>>,
diff --git a/lib/modules/ws2p/ws2p/tests/syncronisation.rs b/lib/modules/ws2p/ws2p/tests/syncronisation.rs
index 48e1bc8a..6d9a2e5e 100644
--- a/lib/modules/ws2p/ws2p/tests/syncronisation.rs
+++ b/lib/modules/ws2p/ws2p/tests/syncronisation.rs
@@ -78,7 +78,7 @@ fn keypair2() -> ed25519::Ed25519KeyPair {
 }
 
 // generate the blockchain data in the temporary directory
-// FIXME now it's juste copying existing data
+// FIXME (now it's just copying existing data)
 fn generate_blockchain_data(tmp_profile_path: &PathBuf, source_path: &str) {
     let source_path = PathBuf::from(source_path.clone());
     let data_dir: PathBuf = [tmp_profile_path.clone(), PathBuf::from("datas")]
-- 
GitLab