Split out peer cmds into new functions

-Add new setting for getpeerinfo cmd
-getpeerinfo api call moved to explorer.js
-Peer geo location api call moved to explorer.js
This commit is contained in:
joeuhren
2020-12-21 16:19:14 -07:00
parent 8219039f42
commit 4a084cdfe1
6 changed files with 86 additions and 35 deletions
+34
View File
@@ -733,6 +733,40 @@ module.exports = {
});
}
},
get_peerinfo: function(cb) {
var cmd = prepareRpcCommand(settings.api_cmds.getpeerinfo);
if (!(cmd.method == '' && cmd.parameters.length == 0)) {
if (settings.use_rpc) {
rpcCommand([{method:cmd.method, parameters: cmd.parameters}], function(response) {
// check if an error msg was received from the rpc server
if (response == 'There was an error. Check your console.')
return cb(null);
else
return cb(response);
});
} else {
var uri = base_url + 'getpeerinfo';
request({uri: uri, json: true, headers: {'User-Agent': 'eiquidus'}}, function (error, response, body) {
// check if an error msg was received from the web api server
if (body == 'There was an error. Check your console.')
return cb(null);
else
return cb(body);
});
}
} else {
// cmd not in use. return null.
return cb(null);
}
},
get_geo_location: function(address, cb) {
request({uri: 'https://freegeoip.app/json/' + address, json: true, headers: {'User-Agent': 'eiquidus'}}, function (error, response, geo) {
return cb(error, geo);
});
},
is_unique: function(array, object, cb) {
var unique = true;