Added an rpc cmd queue
This commit is contained in:
+11
-6
@@ -1,4 +1,5 @@
|
||||
var request = require('postman-request'),
|
||||
async = require('async'),
|
||||
settings = require('./settings'),
|
||||
locale = require('./locale'),
|
||||
Address = require('../models/address');
|
||||
@@ -8,6 +9,15 @@ var base_url = base_server + 'api/';
|
||||
const onode = require('./node');
|
||||
const client = new onode.Client(settings.wallet);
|
||||
|
||||
const rpc_queue = async.queue((task_params, cb) => {
|
||||
client.cmd([task_params], function(err, response) {
|
||||
if (err)
|
||||
return cb('There was an error. Check your console.');
|
||||
else
|
||||
return cb(response);
|
||||
});
|
||||
}, settings.api_cmds.rpc_concurrent_tasks);
|
||||
|
||||
// returns coinbase total sent as current coin supply
|
||||
function coinbase_supply(cb) {
|
||||
Address.findOne({a_id: 'coinbase'}).then((address) => {
|
||||
@@ -22,12 +32,7 @@ function coinbase_supply(cb) {
|
||||
}
|
||||
|
||||
function rpcCommand(params, cb) {
|
||||
client.cmd([{method: params[0].method, params: params[0].parameters}], function(err, response) {
|
||||
if (err)
|
||||
return cb('There was an error. Check your console.');
|
||||
else
|
||||
return cb(response);
|
||||
});
|
||||
rpc_queue.push({method: params[0].method, params: params[0].parameters}, cb);
|
||||
}
|
||||
|
||||
function prepareRpcCommand(cmd, addParams) {
|
||||
|
||||
@@ -1258,6 +1258,8 @@ exports.api_cmds = {
|
||||
// use_rpc: Determine whether to call rpc api cmds directly using the faster rpc method or using the older method via internal http api (true/false)
|
||||
// NOTE: This should always be set to true unless there is a specific need to test or log certain apis
|
||||
"use_rpc": true,
|
||||
// rpc_concurrent_tasks: The maximum number of rpc cmds that can be run simultaneously. Additional rpc cmds will go into a queue and be run on a first-in-first-out basis
|
||||
"rpc_concurrent_tasks": 1,
|
||||
// getnetworkhashps: Returns the estimated network hashes per second. This should be a positive whole number
|
||||
"getnetworkhashps": "getnetworkhashps",
|
||||
// getmininginfo: Returns a json object containing mining-related information
|
||||
|
||||
Reference in New Issue
Block a user