Add support for getblockchaininfo rpc cmd
-sync.supply setting now allows getting moneysupply from getblockchaininfo cmd -README updated with info abour getblockchaininfo cmd
This commit is contained in:
@@ -175,6 +175,7 @@ Table of Contents
|
||||
- **getblock:** Returns an object with information about the block
|
||||
- **getrawtransaction:** Returns raw transaction data
|
||||
- **getinfo:** Returns an object containing various state info
|
||||
- **getblockchaininfo:** Returns an object containing various state info regarding blockchain processing
|
||||
- **getpeerinfo:** Returns data about each connected network node as a json array of objects
|
||||
- **gettxoutsetinfo:** Returns an object with statistics about the unspent transaction output set
|
||||
- **getvotelist:** Returns an object with details regarding the current vote list
|
||||
|
||||
@@ -908,6 +908,34 @@ module.exports = {
|
||||
// cmd not in use. return null.
|
||||
return cb(null);
|
||||
}
|
||||
} else if (settings.sync.supply == 'GETBLOCKCHAININFO') {
|
||||
// attempt to get the supply from the getblockchaininfo or similar api cmd that returns and object containing various state info. Must include a value called "moneysupply" which represents the current running total of coins
|
||||
var cmd = prepareRpcCommand(settings.api_cmds.getblockchaininfo);
|
||||
|
||||
if (!(cmd.method == '' && cmd.parameters.length == 0)) {
|
||||
if (settings.api_cmds.use_rpc) {
|
||||
rpcCommand([{method:cmd.method, parameters: cmd.parameters}], function(response) {
|
||||
// check if an error msg was received from the rpc server
|
||||
if (!response || !response.moneysupply || response == 'There was an error. Check your console.')
|
||||
return cb(null);
|
||||
else
|
||||
return cb(response.moneysupply);
|
||||
});
|
||||
} else {
|
||||
var uri = base_url + 'getblockchaininfo';
|
||||
|
||||
request({uri: uri, json: true}, function (error, response, body) {
|
||||
// check if an error msg was received from the web api server
|
||||
if (!body || !body.moneysupply ||body == 'There was an error. Check your console.')
|
||||
return cb(null);
|
||||
else
|
||||
return cb(body.moneysupply);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// cmd not in use. return null.
|
||||
return cb(null);
|
||||
}
|
||||
} else {
|
||||
// returns coinbase total sent as current coin supply
|
||||
coinbase_supply(function(supply) {
|
||||
|
||||
@@ -43,6 +43,7 @@ module.exports = function() {
|
||||
case 'getrawtransaction':
|
||||
case 'getsupply':
|
||||
case 'getinfo':
|
||||
case 'getblockchaininfo':
|
||||
case 'getpeerinfo':
|
||||
case 'gettxoutsetinfo':
|
||||
case 'getmaxmoney':
|
||||
@@ -156,6 +157,7 @@ module.exports = function() {
|
||||
case 'getconnectioncount':
|
||||
case 'getblockcount':
|
||||
case 'getinfo':
|
||||
case 'getblockchaininfo':
|
||||
case 'getpeerinfo':
|
||||
case 'gettxoutsetinfo':
|
||||
case 'getvotelist':
|
||||
|
||||
@@ -1123,6 +1123,7 @@ exports.sync = {
|
||||
// Valid options:
|
||||
// COINBASE : retrieve the total coins sent from the coinbase (Often used for PoW coins)
|
||||
// GETINFO : retrieved from getinfo rpc cmd (Often used for PoS coins)
|
||||
// GETBLOCKCHAININFO : retrieved from getblockchaininfo rpc cmd
|
||||
// HEAVY: retrieved from getsupply rpc cmd (The "blockchain_specific.heavycoin.enabled" setting must be set to true and the "blockchain_specific.heavycoin.api_cmds.getsupply" setting must be set up correctly for this option to work properly)
|
||||
// BALANCES : get the supply by running a query on the addresses collection and summing up all positive balances (potentially a long running query for blockchains with tons of addresses)
|
||||
// TXOUTSET : retrieved from gettxoutsetinfo rpc cmd
|
||||
@@ -1160,6 +1161,8 @@ exports.api_cmds = {
|
||||
"getrawtransaction": "getrawtransaction",
|
||||
// getinfo: Returns an object containing various state info
|
||||
"getinfo": "getinfo",
|
||||
// getblockchaininfo: Returns an object containing various state info regarding blockchain processing
|
||||
"getblockchaininfo": "getblockchaininfo",
|
||||
// getpeerinfo: Returns data about each connected network node as a json array of objects
|
||||
"getpeerinfo": "getpeerinfo",
|
||||
// gettxoutsetinfo: Returns an object with statistics about the unspent transaction output set
|
||||
|
||||
@@ -1207,6 +1207,7 @@
|
||||
// Valid options:
|
||||
// COINBASE : retrieve the total coins sent from the coinbase (Often used for PoW coins)
|
||||
// GETINFO : retrieved from getinfo rpc cmd (Often used for PoS coins)
|
||||
// GETBLOCKCHAININFO : retrieved from getblockchaininfo rpc cmd
|
||||
// HEAVY: retrieved from getsupply rpc cmd (The "blockchain_specific.heavycoin.enabled" setting must be set to true and the "blockchain_specific.heavycoin.api_cmds.getsupply" setting must be set up correctly for this option to work properly)
|
||||
// BALANCES : get the supply by running a query on the addresses collection and summing up all positive balances (potentially a long running query for blockchains with tons of addresses)
|
||||
// TXOUTSET : retrieved from gettxoutsetinfo rpc cmd
|
||||
@@ -1277,6 +1278,8 @@
|
||||
"getrawtransaction": "getrawtransaction",
|
||||
// getinfo: Returns an object containing various state info
|
||||
"getinfo": "getinfo",
|
||||
// getblockchaininfo: Returns an object containing various state info regarding blockchain processing
|
||||
"getblockchaininfo": "getblockchaininfo",
|
||||
// getpeerinfo: Returns data about each connected network node as a json array of objects
|
||||
"getpeerinfo": "getpeerinfo",
|
||||
// gettxoutsetinfo: Returns an object with statistics about the unspent transaction output set
|
||||
|
||||
Reference in New Issue
Block a user