diff --git a/gui/init.js b/gui/init.js index a607491..67077de 100644 --- a/gui/init.js +++ b/gui/init.js @@ -15,32 +15,27 @@ $(document).ready(function() { StartIguana(); } - if (appConf && !appConf.skipBasiliskNetworkCheck) { - var portcheck; - - function sartcheck() { - portcheck = setInterval(function(){ - Iguana_activehandle().then(function(result){ - console.log(result); - - if (result !== 'error') { - stopcheck(); - $('#loading_status_text').text('Connecting to Basilisk Network...'); - EDEX_DEXgetinfoAll(); - } - }) - //var check = Iguana_activehandle(); - //console.log(check[0]) - }, 2000); - } - - function stopcheck() { - clearInterval(portcheck); - } - - sartcheck(); - //setTimeout(function(){ window.close(); }, 15000); - } else { - window.hide(); + var portcheck; + + function sartcheck() { + portcheck = setInterval(function(){ + Iguana_activehandle().then(function(result){ + console.log(result); + + if (result !== 'error') { + stopcheck(); + $('#loading_status_text').text('Connecting to Basilisk Network...'); + EDEX_DEXgetinfoAll(appConf.skipBasiliskNetworkCheck, appConf.minNotaries); + } + }) + //var check = Iguana_activehandle(); + //console.log(check[0]) + }, 2000); } + + function stopcheck() { + clearInterval(portcheck); + } + + sartcheck(); }); diff --git a/gui/loading.js b/gui/loading.js index d61547d..85bd037 100644 --- a/gui/loading.js +++ b/gui/loading.js @@ -108,7 +108,11 @@ function EDEX_DEXnotarychains() { }); } -function EDEX_DEXgetinfoAll() { +function EDEX_DEXgetinfoAll(skip, minNotaries) { + const remote = require('electron').remote; + var window = remote.getCurrentWindow(); + + if (!skip) { var tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), ajax_data = { 'userpass': tmpIguanaRPCAuth, @@ -117,9 +121,8 @@ function EDEX_DEXgetinfoAll() { }, tmp_index = 0, get_dex_notarychains = IguanaAJAX('http://127.0.0.1:7778', ajax_data).done(function(data) { - //console.log(get_dex_notarychains.responseText); get_dex_notarychains = JSON.parse(get_dex_notarychains.responseText); - //console.log(get_dex_notarychains) + get_dex_notarychains = get_dex_notarychains.splice(0, minNotaries); $.each(get_dex_notarychains, function( coin_index, coin_value ) { console.log(coin_index + ': ' + coin_value); @@ -129,8 +132,7 @@ function EDEX_DEXgetinfoAll() { 'agent': 'dex', 'method': 'getinfo', 'symbol': coin_value - }, - basiliskMinNotariesConnected = 10; + }; console.log(ajax_data); @@ -148,10 +150,8 @@ function EDEX_DEXgetinfoAll() { $('#loading_sub_status_output_text').text('Output: Connected'); } - if ( tmp_index == 10 ) { + if ( tmp_index == minNotaries ) { console.log('min notaries connected'); - const remote = require('electron').remote; - var window = remote.getCurrentWindow(); window.hide(); } }).fail(function(xhr, textStatus, error) { @@ -165,4 +165,7 @@ function EDEX_DEXgetinfoAll() { } }); }); + } else { + window.hide(); + } } \ No newline at end of file diff --git a/main.js b/main.js index e9d1740..3d09220 100644 --- a/main.js +++ b/main.js @@ -9,14 +9,14 @@ const electron = require('electron'), os = require('os'), spawn = require('child_process').spawn, exec = require('child_process').exec, - fixPath = require('fix-path'); + fixPath = require('fix-path'); var express = require('express'), bodyParser = require('body-parser'), fs = require('fs'), fsnode = require('fs'), fs = require('fs-extra'), mkdirp = require('mkdirp'), - pm2 = require('pm2'); + pm2 = require('pm2'); Promise = require('bluebird'); @@ -63,7 +63,7 @@ guiapp.use('/shepherd', shepherd); var rungui = guiapp.listen(appConfig.iguanaAppPort, function () { console.log('guiapp listening on port ' + appConfig.iguanaAppPort + '!'); -}) +}); module.exports = guiapp; // END GUI App Settings diff --git a/routes/shepherd.js b/routes/shepherd.js index 7c866ce..6540f11 100644 --- a/routes/shepherd.js +++ b/routes/shepherd.js @@ -62,6 +62,7 @@ shepherd.appConfig = { "iguanaGuiOnly": false, "manualIguanaStart": false, "skipBasiliskNetworkCheck": false, + "minNotaries": 50, "host": "127.0.0.1", "iguanaAppPort": 17777, "iguanaCorePort": 7778, @@ -101,7 +102,7 @@ shepherd.post('/debuglog', function(req, res) { 'msg': 'success', 'result': result }; - + res.end(JSON.stringify(_obj)); }, function(result) { var _obj = { @@ -109,7 +110,7 @@ shepherd.post('/debuglog', function(req, res) { 'result': result }; - res.end(JSON.stringify(_obj)); + res.end(JSON.stringify(_obj)); }); }); @@ -126,7 +127,7 @@ shepherd.post('/herd', function(req, res) { 'msg': 'success', 'result': 'result' }; - + res.end(JSON.stringify(obj)); }); @@ -149,11 +150,11 @@ shepherd.post('/herdlist', function(req, res) { console.log(list[0].pid) // print pid of IGUANA proc var obj = { - 'herdname': req.body.herdname, + 'herdname': req.body.herdname, 'status': list[0].pm2_env.status, 'pid': list[0].pid }; - + res.end(JSON.stringify(obj)); }); }); @@ -170,7 +171,7 @@ shepherd.post('/slay', function(req, res) { 'msg': 'success', 'result': 'result' }; - + res.end(JSON.stringify(obj)); }); @@ -185,7 +186,7 @@ shepherd.post('/setconf', function(req, res) { 'msg': 'success', 'result': 'result' }; - + res.end(JSON.stringify(obj)); }); @@ -202,7 +203,7 @@ shepherd.post('/getconf', function(req, res) { 'msg': 'success', 'result': confpath }; - + res.end(JSON.stringify(obj)); });