Browse Source

sync only forks(wip)

all-modes
pbca26 8 years ago
parent
commit
9bec23cb02
  1. 2
      gui/EasyDEX-GUI
  2. 72
      routes/shepherd.js

2
gui/EasyDEX-GUI

@ -1 +1 @@
Subproject commit 59ff487c1f068700d381b07a4e873d2ab9d7c86d
Subproject commit 04af9b16553cee3ca7cba950ebf1072f98ee0ece

72
routes/shepherd.js

@ -16,9 +16,8 @@ const electron = require('electron'),
request = require('request'),
async = require('async'),
rimraf = require('rimraf'),
portscanner = require('portscanner');
Promise = require('bluebird');
portscanner = require('portscanner'),
Promise = require('bluebird');
const fixPath = require('fix-path');
var ps = require('ps-node'),
@ -26,7 +25,9 @@ var ps = require('ps-node'),
//coincli = require('../private/coincli.js'),
assetChainPorts = require('./ports.js')
shepherd = express.Router(),
iguanaInstanceRegistry = {};
iguanaInstanceRegistry = {},
syncOnlyIguanaInstanceInfo = {},
syncOnlyInstanceInterval = -1;
// IGUANA FILES AND CONFIG SETTINGS
var iguanaConfsDirSrc = path.join(__dirname, '../assets/deps/confs'),
@ -236,6 +237,59 @@ shepherd.setIO = function(io) {
cache.setVar('iguanaDir', iguanaDir);
cache.setVar('appConfig', shepherd.appConfig);
shepherd.getSyncOnlyForksInfo = function() {
async.forEachOf(iguanaInstanceRegistry, function(data, port) {
if (iguanaInstanceRegistry[port].mode.indexOf('/sync') > -1) {
syncOnlyIguanaInstanceInfo[port] = {};
request({
url: 'http://localhost:' + port + '/api/bitcoinrpc/getinfo?userpass=tmpIgRPCUser@1234',
method: 'GET'
}, function (error, response, body) {
if (response && response.statusCode && response.statusCode === 200) {
console.log(body);
try {
syncOnlyIguanaInstanceInfo[port].getinfo = JSON.parse(body);
} catch(e) {}
} else {
// TODO: error
}
});
request({
url: 'http://localhost:' + port + '/api/SuperNET/activehandle?userpass=tmpIgRPCUser@1234',
method: 'GET'
}, function (error, response, body) {
if (response && response.statusCode && response.statusCode === 200) {
console.log(body);
try {
syncOnlyIguanaInstanceInfo[port].activehandle = JSON.parse(body);
} catch(e) {}
} else {
// TODO: error
}
});
}
});
}
shepherd.get('/forks/info/start', function(req, res, next) {
var successObj = {
'msg': 'success',
'result': 'started'
};
res.end(JSON.stringify(successObj));
shepherd.getSyncOnlyForksInfo();
});
shepherd.get('/forks/info/show', function(req, res, next) {
var successObj = {
'msg': 'success',
'result': JSON.stringify(syncOnlyIguanaInstanceInfo)
};
res.end(JSON.stringify(successObj));
});
/*
* type: GET
*
@ -337,6 +391,16 @@ shepherd.post('/forks', function(req, res, next) {
};
cache.setVar('iguanaInstances', iguanaInstanceRegistry);
// get sync only forks info
if (syncOnlyInstanceInterval === -1) {
setTimeout(function() {
shepherd.getSyncOnlyForksInfo();
}, 5000);
setInterval(function() {
shepherd.getSyncOnlyForksInfo();
}, 20000);
}
var successObj = {
'msg': 'success',
'result': _port

Loading…
Cancel
Save