added support for customizing daemon api cmds [getmasternodecount only so far]
This commit is contained in:
+7
-4
@@ -89,10 +89,13 @@ module.exports = {
|
||||
},
|
||||
|
||||
get_masternodecount: function(cb) {
|
||||
var uri = base_url + 'getmasternodecount';
|
||||
request({uri: uri, json: true, headers: {'User-Agent': 'eiquidus'}}, function (error, response, body) {
|
||||
return cb(body);
|
||||
});
|
||||
if (settings.api_cmds.masternode_count != '') {
|
||||
var uri = base_url + 'getmasternodecount';
|
||||
request({uri: uri, json: true, headers: {'User-Agent': 'eiquidus'}}, function (error, response, body) {
|
||||
return cb(body);
|
||||
});
|
||||
} else
|
||||
return cb({"total":0,"enabled":0});
|
||||
},
|
||||
|
||||
get_blockcount: function(cb) {
|
||||
|
||||
+52
-42
@@ -1,5 +1,6 @@
|
||||
var onode = require('./node');
|
||||
var express = require('express');
|
||||
var settings = require('./settings');
|
||||
|
||||
module.exports = function(){
|
||||
function express_app(){
|
||||
@@ -30,6 +31,7 @@ module.exports = function(){
|
||||
|
||||
if (method == 'sendmany' ||
|
||||
method == 'getmasternodecountonline' ||
|
||||
method == 'getmasternodecount' ||
|
||||
method == 'getmasternodelist' ||
|
||||
method == 'getvotelist') {
|
||||
command = specialApiCase(method);
|
||||
@@ -73,50 +75,58 @@ module.exports = function(){
|
||||
|
||||
function specialApiCase(method_name){
|
||||
var params = [];
|
||||
if(method_name == 'sendmany'){
|
||||
var after_account = false;
|
||||
var before_min_conf = true;
|
||||
var address_info = {};
|
||||
for(var parameter in query_parameters){
|
||||
if(query_parameters.hasOwnProperty(parameter)){
|
||||
if(parameter == 'minconf'){
|
||||
before_min_conf = false;
|
||||
params.push(address_info);
|
||||
|
||||
switch(method_name) {
|
||||
case 'sendmany':
|
||||
var after_account = false;
|
||||
var before_min_conf = true;
|
||||
var address_info = {};
|
||||
for(var parameter in query_parameters){
|
||||
if(query_parameters.hasOwnProperty(parameter)){
|
||||
if(parameter == 'minconf'){
|
||||
before_min_conf = false;
|
||||
params.push(address_info);
|
||||
}
|
||||
var param = query_parameters[parameter];
|
||||
if(!isNaN(param)){
|
||||
param = parseFloat(param);
|
||||
}
|
||||
if(after_account && before_min_conf){
|
||||
address_info[parameter] = param;
|
||||
}
|
||||
else {
|
||||
params.push(param);
|
||||
}
|
||||
if(parameter == 'account') after_account = true;
|
||||
}
|
||||
var param = query_parameters[parameter];
|
||||
if(!isNaN(param)){
|
||||
param = parseFloat(param);
|
||||
}
|
||||
if(after_account && before_min_conf){
|
||||
address_info[parameter] = param;
|
||||
}
|
||||
else{
|
||||
params.push(param);
|
||||
}
|
||||
if(parameter == 'account') after_account = true;
|
||||
}
|
||||
}
|
||||
if(before_min_conf){
|
||||
params.push(address_info);
|
||||
}
|
||||
}
|
||||
|
||||
//not liking this
|
||||
|
||||
if(method_name == 'getvotelist'){
|
||||
method_name = 'masternodelist'
|
||||
params.push('votes');
|
||||
}
|
||||
|
||||
if(method_name == 'getmasternodelist'){
|
||||
method_name = 'masternode'
|
||||
params.push('list');
|
||||
}
|
||||
|
||||
if(method_name == 'getmasternodecountonline'){
|
||||
method_name = 'masternode';
|
||||
params.push('count');
|
||||
params.push('enabled');
|
||||
if(before_min_conf){
|
||||
params.push(address_info);
|
||||
}
|
||||
break;
|
||||
case 'getvotelist':
|
||||
method_name = 'masternodelist'
|
||||
params.push('votes');
|
||||
break;
|
||||
case 'getmasternodelist':
|
||||
method_name = 'masternode'
|
||||
params.push('list');
|
||||
break;
|
||||
case 'getmasternodecountonline':
|
||||
method_name = 'masternode';
|
||||
params.push('count');
|
||||
params.push('enabled');
|
||||
break;
|
||||
case 'getmasternodecount':
|
||||
// split cmd by spaces
|
||||
var sSplit = settings.api_cmds.masternode_count.split(' ');
|
||||
for (i=0; i<sSplit.length; i++) {
|
||||
if (i==0)
|
||||
method_name = sSplit[i];
|
||||
else
|
||||
params.push(sSplit[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return [{
|
||||
|
||||
@@ -161,6 +161,11 @@ exports.corsorigin = "*";
|
||||
exports.labels = {};
|
||||
exports.burned_coins = [];
|
||||
|
||||
// Customized API commands
|
||||
exports.api_cmds = {
|
||||
"masternode_count": "getmasternodecount"
|
||||
};
|
||||
|
||||
exports.reloadSettings = function reloadSettings() {
|
||||
// Discover where the settings file lives
|
||||
var settingsFilename = "settings.json";
|
||||
|
||||
+11
-1
@@ -207,5 +207,15 @@
|
||||
// "address": "EUzgbt1r5AFzoZXK6WgTzM8kBBPJU1SX8E"
|
||||
// }
|
||||
//]
|
||||
"burned_coins": []
|
||||
"burned_coins": [],
|
||||
|
||||
// Customized API commands
|
||||
// Not all blockchains utilize the same rpc cmds for accessing the internal daemon api
|
||||
// Leave the value blank for any cmd that should not be used
|
||||
// The following cmd-line calls to the daemon can be overridden:
|
||||
//
|
||||
// masternode_count: This should return an array of masternode counts where one key in the array must be named "total" and one key must be named "enabled" which are used to determine how many masternodes are offline (not enabled)
|
||||
"api_cmds": {
|
||||
"masternode_count": "getmasternodecount"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user