From 433bb294384c25e890999660f3441161c8700663 Mon Sep 17 00:00:00 2001
From: cgeek <cem.moreau@gmail.com>
Date: Fri, 20 Jan 2017 08:15:04 +0100
Subject: [PATCH] [fix] Make Duniter work with WebUI

---
 app/lib/system/network.js |  2 +-
 index.js                  | 33 ++++++++++++++++++---------------
 package.json              |  9 +++++----
 3 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/app/lib/system/network.js b/app/lib/system/network.js
index b14be0f28..0e296179a 100644
--- a/app/lib/system/network.js
+++ b/app/lib/system/network.js
@@ -15,7 +15,7 @@ module.exports = {
 
   listInterfaces: bmapiMethods.listInterfaces,
 
-  upnpConf: (noupnp) => bmapiMethods.upnpConf(noupnp, logger),
+  upnpConf: (noupnp, logger) => bmapiMethods.upnpConf(noupnp, logger),
 
   getRandomPort: bmapiMethods.getRandomPort,
 
diff --git a/index.js b/index.js
index 151cf07d6..b3cc4fada 100644
--- a/index.js
+++ b/index.js
@@ -251,21 +251,24 @@ function Stack(dependencies) {
           }
         }
       }
+      // All inputs write to global INPUT stream
+      for (const module of streams.input) module.pipe(INPUT);
+      // All processes read from global INPUT stream
+      for (const module of streams.process) INPUT.pipe(module);
+      // All processes write to global PROCESS stream
+      for (const module of streams.process) module.pipe(PROCESS);
+      // All ouputs read from global PROCESS stream
+      for (const module of streams.output) PROCESS.pipe(module);
 
       return yield command.onDatabaseExecute(server, conf, program, params,
 
         // Start services and streaming between them
         () => co(function*() {
-          // All inputs write to global INPUT stream
-          for (const module of streams.input) module.pipe(INPUT);
-          // All processes read from global INPUT stream
-          for (const module of streams.process) INPUT.pipe(module);
-          // All processes write to global PROCESS stream
-          for (const module of streams.process) module.pipe(PROCESS);
-          // All ouputs read from global PROCESS stream
-          for (const module of streams.output) PROCESS.pipe(module);
           // Any streaming module must implement a `startService` method
-          const modules = streams.input.concat(streams.process).concat(streams.output).concat(streams.neutral);
+          for (const m of streams.input) {
+            yield m.startService();
+          }
+          const modules = [].concat(streams.process).concat(streams.output).concat(streams.neutral);
           yield modules.map(module => module.startService());
         }),
 
@@ -274,13 +277,13 @@ function Stack(dependencies) {
           const modules = streams.input.concat(streams.process).concat(streams.output);
           // Any streaming module must implement a `stopService` method
           yield modules.map(module => module.stopService());
-          // Stop reading inputs
-          for (const module of streams.input) module.unpipe();
+          // // Stop reading inputs
+          // for (const module of streams.input) module.unpipe();
           // Stop reading from global INPUT
-          INPUT.unpipe();
-          for (const module of streams.process) module.unpipe();
-          // Stop reading from global PROCESS
-          PROCESS.unpipe();
+          // INPUT.unpipe();
+          // for (const module of streams.process) module.unpipe();
+          // // Stop reading from global PROCESS
+          // PROCESS.unpipe();
         }));
     } catch (e) {
       server.disconnect();
diff --git a/package.json b/package.json
index a53f122b4..1f1c2c899 100644
--- a/package.json
+++ b/package.json
@@ -42,11 +42,11 @@
     "colors": "1.1.2",
     "commander": "2.9.0",
     "daemonize2": "0.4.2",
-    "duniter-bma": "0.2.0",
-    "duniter-crawler": "0.2.1",
-    "duniter-keypair": "0.1.2",
-    "duniter-prover": "0.2.0",
+    "duniter-bma": "^0.2.1",
     "duniter-common": "0.1.0",
+    "duniter-crawler": "^0.2.2",
+    "duniter-keypair": "^0.2.0",
+    "duniter-prover": "^0.2.1",
     "event-stream": "3.3.4",
     "inquirer": "0.8.5",
     "jison": "0.4.17",
@@ -71,6 +71,7 @@
   },
   "devDependencies": {
     "coveralls": "2.11.4",
+    "duniter-ui": "^0.3.0",
     "eslint": "3.13.1",
     "eslint-plugin-mocha": "4.8.0",
     "istanbul": "0.4.0",
-- 
GitLab