Browse Source

removed commented out code

all-modes
Petr Balashov 8 years ago
parent
commit
5bb5b3b5d6
  1. 3
      gui/main.html
  2. 46
      main.js
  3. 13
      routes/fetchparams.js
  4. 8
      routes/mock.js
  5. 62
      routes/shepherd.js

3
gui/main.html

@ -17,7 +17,6 @@
var ajax_data = {"herd":"iguana"}; var ajax_data = {"herd":"iguana"};
console.log(ajax_data); console.log(ajax_data);
$.ajax({ $.ajax({
//async: false,
type: 'POST', type: 'POST',
data: JSON.stringify(ajax_data), data: JSON.stringify(ajax_data),
url: 'http://127.0.0.1:17777/shepherd/herd', url: 'http://127.0.0.1:17777/shepherd/herd',
@ -41,7 +40,6 @@
var ajax_data = {"herd":"corsproxy"}; var ajax_data = {"herd":"corsproxy"};
console.log(ajax_data); console.log(ajax_data);
$.ajax({ $.ajax({
//async: false,
type: 'POST', type: 'POST',
data: JSON.stringify(ajax_data), data: JSON.stringify(ajax_data),
url: 'http://127.0.0.1:17777/shepherd/herd', url: 'http://127.0.0.1:17777/shepherd/herd',
@ -65,7 +63,6 @@
var ajax_data = {"herd":"komodod"}; var ajax_data = {"herd":"komodod"};
console.log(ajax_data); console.log(ajax_data);
$.ajax({ $.ajax({
//async: false,
type: 'POST', type: 'POST',
data: JSON.stringify(ajax_data), data: JSON.stringify(ajax_data),
url: 'http://127.0.0.1:17777/shepherd/herd', url: 'http://127.0.0.1:17777/shepherd/herd',

46
main.js

@ -112,18 +112,6 @@ var guipath = path.join(__dirname, '/gui');
guiapp.use('/gui', express.static(guipath)); guiapp.use('/gui', express.static(guipath));
guiapp.use('/shepherd', shepherd); guiapp.use('/shepherd', shepherd);
/*if (cluster.isMaster && process.env.NODE_ENV !== "development") {
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
}
console.log(cluster)
*/
/*var rungui = guiapp.listen(appConfig.iguanaAppPort, function () {
console.log('guiapp listening on port ' + appConfig.iguanaAppPort + '!');
});*/
var server = require('http').createServer(guiapp), var server = require('http').createServer(guiapp),
io = require('socket.io').listen(server); io = require('socket.io').listen(server);
@ -403,12 +391,8 @@ function createWindow (status) {
} }
} }
//app.on('ready', function() {
//createLoadingWindow
//})
app.on('window-all-closed', function () { app.on('window-all-closed', function () {
//if (os.platform() !== 'win32') { ig.kill(); } //if (os.platform() !== 'win32') { ig.kill(); }
// in osx apps stay active in menu bar until explictly closed or quitted by CMD Q // in osx apps stay active in menu bar until explictly closed or quitted by CMD Q
// so we do not kill the app --> for the case user clicks again on the iguana icon // so we do not kill the app --> for the case user clicks again on the iguana icon
// we open just a new window and respawn iguana proc // we open just a new window and respawn iguana proc
@ -417,34 +401,32 @@ app.on('window-all-closed', function () {
}*/ }*/
}) })
//Emitted before the application starts closing its windows. // Emitted before the application starts closing its windows.
//Calling event.preventDefault() will prevent the default behaviour, which is terminating the application. // Calling event.preventDefault() will prevent the default behaviour, which is terminating the application.
app.on('before-quit', function (event) { app.on('before-quit', function (event) {
console.log('before-quit'); console.log('before-quit');
if (mainWindow === null && loadingWindow != null) { //mainWindow not intitialised and loadingWindow not dereferenced if (mainWindow === null && loadingWindow != null) { // mainWindow not intitialised and loadingWindow not dereferenced
//loading window is still open // loading window is still open
if (os.platform() === 'darwin' || os.platform() === 'linux') {
closeAppAfterLoading = true;
let code = `$('#loading_status_text').html('Preparing to shutdown the wallet.<br/>Please wait while all daemons are closed...')`;
loadingWindow.webContents.executeJavaScript(code);
}
console.log('before-quit prevented'); console.log('before-quit prevented');
closeAppAfterLoading = true;
let code = `$('#loading_status_text').html('Preparing to shutdown the wallet.<br/>Please wait while all daemons are closed...')`;
loadingWindow.webContents.executeJavaScript(code);
event.preventDefault(); event.preventDefault();
} }
}); });
//Emitted when all windows have been closed and the application will quit. // Emitted when all windows have been closed and the application will quit.
//Calling event.preventDefault() will prevent the default behaviour, which is terminating the application. // Calling event.preventDefault() will prevent the default behaviour, which is terminating the application.
app.on('will-quit', function (event) { app.on('will-quit', function (event) {
if (mainWindow === null && loadingWindow != null) { if (mainWindow === null && loadingWindow != null) {
//loading window is still open // loading window is still open
console.log('will-quit while loading window active'); console.log('will-quit while loading window active');
event.preventDefault(); event.preventDefault();
} }
}); });
//Emitted when the application is quitting. // Emitted when the application is quitting.
//Calling event.preventDefault() will prevent the default behaviour, which is terminating the application. // Calling event.preventDefault() will prevent the default behaviour, which is terminating the application.
app.on('quit', function (event) { app.on('quit', function (event) {
if (mainWindow === null && loadingWindow != null) { if (mainWindow === null && loadingWindow != null) {
console.log('quit while loading window active'); console.log('quit while loading window active');
@ -454,6 +436,6 @@ app.on('quit', function (event) {
app.on('activate', function () { app.on('activate', function () {
if (mainWindow === null) { if (mainWindow === null) {
//createWindow('open'); // createWindow('open');
} }
}); });

13
routes/fetchparams.js

@ -33,8 +33,6 @@ if (os.platform() === 'linux') {
var PARAMS_DIR = process.env.HOME + '/.zcash-params'; var PARAMS_DIR = process.env.HOME + '/.zcash-params';
} }
//PARAMS_DIR="$HOME/Library/Application Support/ZcashParams"
var SPROUT_FILES_DATA = [ var SPROUT_FILES_DATA = [
{ {
'file': 'sprout-proving.key', 'file': 'sprout-proving.key',
@ -46,14 +44,7 @@ var SPROUT_FILES_DATA = [
]; ];
var SPROUT_DL_URL = 'https://z.cash/downloads/'; var SPROUT_DL_URL = 'https://z.cash/downloads/';
//console.log(SPROUT_FILES_DATA);
SPROUT_FILES_DATA.forEach(function(value, index) { SPROUT_FILES_DATA.forEach(function(value, index) {
//console.log(index);
//console.log(value);
//console.log(value.file);
//console.log(value.hash);
fs.exists(value.file, function(exists) { fs.exists(value.file, function(exists) {
if (exists) { if (exists) {
console.log(value.file + ' already exists at location.'); console.log(value.file + ' already exists at location.');
@ -94,12 +85,12 @@ SPROUT_FILES_DATA.forEach(function(value, index) {
}) })
.on('end', function () { .on('end', function () {
// Do something after request finishes // Do something after request finishes
console.log('download finished.') console.log('download finished.');
var result = 'File ==> ' + value.file + ': DOWNLOADED'; var result = 'File ==> ' + value.file + ': DOWNLOADED';
}) })
.pipe(fs.createWriteStream(value.file)); .pipe(fs.createWriteStream(value.file));
console.log(result) console.log(result);
resolve(result); resolve(result);
}) })
} }

8
routes/mock.js

@ -23,7 +23,13 @@ mock.get = function(req, res, next) {
if (_url.indexOf('/bitcoinrpc/getaddressesbyaccount') > -1) { if (_url.indexOf('/bitcoinrpc/getaddressesbyaccount') > -1) {
console.log(_url.indexOf('/bitcoinrpc/getaddressesbyaccount')); console.log(_url.indexOf('/bitcoinrpc/getaddressesbyaccount'));
res.end(JSON.stringify({ res.end(JSON.stringify({
'result': ["RDbGxL8QYdEp8sMULaVZS2E6XThcTKT9Jd","RL4orv22Xch7PhM5w9jUHhVQhX6kF6GkfS","RUrxvPTEKGWEDTvAtgiqbUTTFE53Xdpj8a","RPJoLDa7RezvfUUBr7R3U8wrP16AgUsNw3","RQPTpRJEeafNx5hkDzgjcsPyU4E8RFVApT"] 'result': [
"RDbGxL8QYdEp8sMULaVZS2E6XThcTKT9Jd",
"RL4orv22Xch7PhM5w9jUHhVQhX6kF6GkfS",
"RUrxvPTEKGWEDTvAtgiqbUTTFE53Xdpj8a",
"RPJoLDa7RezvfUUBr7R3U8wrP16AgUsNw3",
"RQPTpRJEeafNx5hkDzgjcsPyU4E8RFVApT"
]
})); }));
} }
if (_url.indexOf('/api/dex/listunspent') > -1 || if (_url.indexOf('/api/dex/listunspent') > -1 ||

62
routes/shepherd.js

@ -305,10 +305,7 @@ shepherd.post('/debuglog', function(req, res) {
*/ */
shepherd.post('/herd', function(req, res) { shepherd.post('/herd', function(req, res) {
console.log('======= req.body ======='); console.log('======= req.body =======');
//console.log(req);
console.log(req.body); console.log(req.body);
//console.log(req.body.herd);
//console.log(req.body.options);
herder(req.body.herd, req.body.options); herder(req.body.herd, req.body.options);
@ -320,52 +317,12 @@ shepherd.post('/herd', function(req, res) {
res.end(JSON.stringify(obj)); res.end(JSON.stringify(obj));
}); });
/*
*
* ajax_data = { 'command': 'getinfo' };
*
* console.log(ajax_data);
* $.ajax({
* async: false,
* type: 'POST',
* data: JSON.stringify(ajax_data),
* url: 'http://127.0.0.1:17777/shepherd/kmdcli',
* contentType: 'application/json', // send as JSON
* success: function(data, textStatus, jqXHR) {
* var AjaxOutputData = JSON.parse(data);
* console.log(AjaxOutputData);
* },
* error: function(xhr, textStatus, error) {
* console.log(xhr.statusText);
* console.log(textStatus);
* console.log(error);
* }
* });
*
*/
/*shepherd.post('/kmdcli', function(req, res) {
console.log('======= req.body =======');
//console.log(req);
console.log(req.body);
console.log(req.body.command);
kmdcli.command(req.body.command, function(err, command) {
console.log(command);
res.end(JSON.stringify(command));
});
});*/
/* /*
* type: POST * type: POST
* params: herdname * params: herdname
*/ */
shepherd.post('/herdlist', function(req, res) { shepherd.post('/herdlist', function(req, res) {
//console.log('======= req.body =======');
//console.log(req);
//console.log(req.body);
console.log(req.body.herdname); console.log(req.body.herdname);
//console.log(req.body.options);
pm2.connect(true, function(err) { pm2.connect(true, function(err) {
if (err) throw err; // TODO: proper error handling if (err) throw err; // TODO: proper error handling
@ -394,9 +351,7 @@ shepherd.post('/herdlist', function(req, res) {
*/ */
shepherd.post('/slay', function(req, res) { shepherd.post('/slay', function(req, res) {
console.log('======= req.body ======='); console.log('======= req.body =======');
//console.log(req);
console.log(req.body); console.log(req.body);
//console.log(req.body.slay);
slayer(req.body.slay); slayer(req.body.slay);
var obj = { var obj = {
@ -412,9 +367,7 @@ shepherd.post('/slay', function(req, res) {
*/ */
shepherd.post('/setconf', function(req, res) { shepherd.post('/setconf', function(req, res) {
console.log('======= req.body ======='); console.log('======= req.body =======');
//console.log(req);
console.log(req.body); console.log(req.body);
//console.log(req.body.chain);
if (os.platform() === 'win32' && req.body.chain == 'komodod') { if (os.platform() === 'win32' && req.body.chain == 'komodod') {
setkomodoconf = spawn(path.join(__dirname, '../assets/bin/win64/genkmdconf.bat')); setkomodoconf = spawn(path.join(__dirname, '../assets/bin/win64/genkmdconf.bat'));
@ -435,9 +388,7 @@ shepherd.post('/setconf', function(req, res) {
*/ */
shepherd.post('/getconf', function(req, res) { shepherd.post('/getconf', function(req, res) {
console.log('======= req.body ======='); console.log('======= req.body =======');
//console.log(req);
console.log(req.body); console.log(req.body);
//console.log(req.body.chain);
var confpath = getConf(req.body.chain); var confpath = getConf(req.body.chain);
console.log('got conf path is:'); console.log('got conf path is:');
@ -712,7 +663,6 @@ function herder(flock, data) {
exec_mode : 'fork', exec_mode : 'fork',
cwd: komodoDir, cwd: komodoDir,
args: data.ac_options args: data.ac_options
//args: ["-server", "-ac_name=USD", "-addnode=78.47.196.146"], //separate the params with commas
}, function(err, apps) { }, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2 pm2.disconnect(); // Disconnect from PM2
if (err) if (err)
@ -741,7 +691,6 @@ function herder(flock, data) {
exec_mode : 'fork', exec_mode : 'fork',
cwd: zcashDir, cwd: zcashDir,
args: data.ac_options args: data.ac_options
//args: ["-server", "-ac_name=USD", "-addnode=78.47.196.146"], //separate the params with commas
}, function(err, apps) { }, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2 pm2.disconnect(); // Disconnect from PM2
if (err) if (err)
@ -778,7 +727,6 @@ function slayer(flock) {
console.log(flock); console.log(flock);
pm2.delete(flock, function(err, ret) { pm2.delete(flock, function(err, ret) {
//console.log(err);
pm2.disconnect(); pm2.disconnect();
console.log(ret); console.log(ret);
}); });
@ -882,8 +830,6 @@ function setConf(flock) {
var result = 'CheckConf is done'; var result = 'CheckConf is done';
setconf.status(DaemonConfPath, function(err, status) { setconf.status(DaemonConfPath, function(err, status) {
//console.log(status[0]);
//console.log(status[0].rpcuser);
var rpcuser = function() { var rpcuser = function() {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
var result = 'checking rpcuser...'; var result = 'checking rpcuser...';
@ -901,7 +847,6 @@ function setConf(flock) {
}); });
} }
//console.log(result)
resolve(result); resolve(result);
}); });
} }
@ -923,7 +868,6 @@ function setConf(flock) {
}); });
} }
//console.log(result)
resolve(result); resolve(result);
}); });
} }
@ -943,7 +887,6 @@ function setConf(flock) {
}); });
} }
//console.log(result)
resolve(result); resolve(result);
}); });
} }
@ -952,7 +895,7 @@ function setConf(flock) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
var result = 'checking addnode...'; var result = 'checking addnode...';
if(status[0].hasOwnProperty('addnode')) { if (status[0].hasOwnProperty('addnode')) {
console.log('addnode: OK'); console.log('addnode: OK');
} else { } else {
console.log('addnode: NOT FOUND') console.log('addnode: NOT FOUND')
@ -970,7 +913,6 @@ function setConf(flock) {
}); });
} }
//console.log(result)
resolve(result); resolve(result);
}); });
} }
@ -980,7 +922,7 @@ function setConf(flock) {
return rpcpass(); return rpcpass();
}) })
.then(server) .then(server)
.then(addnode) .then(addnode);
}); });
setTimeout(function() { setTimeout(function() {

Loading…
Cancel
Save