From 923bb465691aff338480a632bc8275e4c2094127 Mon Sep 17 00:00:00 2001 From: Zyuhel Date: Wed, 30 Jan 2019 15:22:28 +0300 Subject: [PATCH 1/2] return websocket port in /api/node/status endpoint --- modules/node.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/node.js b/modules/node.js index 98cbf573..b7f8724f 100644 --- a/modules/node.js +++ b/modules/node.js @@ -107,16 +107,20 @@ Node.prototype.shared = { getStatus: function (req, cb) { var lastBlock = modules.blocks.lastBlock.get(); var wsClientEnabled = false; + var wsClientOptions = { + enabled: false + }; if (library.config.wsClient) { if (library.config.wsClient.enabled) { - wsClientEnabled = true; + wsClientOptions.enabled = true; + wsClientOptions.port = library.config.wsClient.portWS; } } + + return setImmediate(cb, null, { - wsClient: { - enabled: wsClientEnabled - }, + wsClient: wsClientOptions, network: { broadhash: modules.system.getBroadhash(), epoch: constants.epochTime, From 935a7dc577693b575d8f9a4ac6a51154663dac20 Mon Sep 17 00:00:00 2001 From: Zyuhel Date: Wed, 30 Jan 2019 15:35:57 +0300 Subject: [PATCH 2/2] light refactoring --- modules/node.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/node.js b/modules/node.js index b7f8724f..a84dacad 100644 --- a/modules/node.js +++ b/modules/node.js @@ -100,13 +100,16 @@ Node.prototype.shared = { * @return {Function} cb Callback function from params (through setImmediate) * @return {Object} cb.err Always return `null` here * @return {Object} cb.obj Anonymous object with version info - * @return {String} cb.obj.build Build information (if available, otherwise '') - * @return {String} cb.obj.commit Hash of last git commit (if available, otherwise '') - * @return {String} cb.obj.version Lisk version from config file + * @return {Object} cb.obj.network Anonymous object with network info + * @return {Object} cb.obj.wsClient Anonymous object with WebSocket Client info + * @return {Boolean} cb.obj.wsClient.enabled are webSockets available. + * @return {Object} cb.obj.version Anonymous object with version info + * @return {String} cb.obj.version.build Build information (if available, otherwise '') + * @return {String} cb.obj.version.commit Hash of last git commit (if available, otherwise '') + * @return {String} cb.obj.version.version ADAMANT version from package.json */ getStatus: function (req, cb) { var lastBlock = modules.blocks.lastBlock.get(); - var wsClientEnabled = false; var wsClientOptions = { enabled: false }; @@ -116,11 +119,8 @@ Node.prototype.shared = { wsClientOptions.port = library.config.wsClient.portWS; } } - - return setImmediate(cb, null, { - wsClient: wsClientOptions, network: { broadhash: modules.system.getBroadhash(), epoch: constants.epochTime, @@ -135,7 +135,8 @@ Node.prototype.shared = { build: library.build, commit: library.lastCommit, version: library.config.version - } + }, + wsClient: wsClientOptions }); } };