Add use_rpc setting
This commit is contained in:
@@ -271,6 +271,7 @@ app.set('website', settings.website);
|
||||
|
||||
app.set('genesis_block', settings.genesis_block);
|
||||
app.set('index', settings.index);
|
||||
app.set('use_rpc', settings.use_rpc);
|
||||
app.set('heavy', settings.heavy);
|
||||
app.set('lock_during_index', settings.lock_during_index);
|
||||
app.set('txcount', settings.txcount);
|
||||
|
||||
+35
-8
@@ -6,6 +6,9 @@ var base_server = 'http://127.0.0.1:' + settings.port + "/";
|
||||
|
||||
var base_url = base_server + 'api/';
|
||||
|
||||
const Client = require('node');
|
||||
const client = new Client(settings.wallet);
|
||||
|
||||
// returns coinbase total sent as current coin supply
|
||||
function coinbase_supply(cb) {
|
||||
Address.findOne({a_id: 'coinbase'}, function(err, address) {
|
||||
@@ -106,17 +109,41 @@ module.exports = {
|
||||
},
|
||||
|
||||
get_blockhash: function(height, cb) {
|
||||
var uri = base_url + 'getblockhash?height=' + height;
|
||||
request({uri: uri, json: true, headers: {'User-Agent': 'eiquidus'}}, function (error, response, body) {
|
||||
return cb(body);
|
||||
});
|
||||
if (settings.use_rpc) {
|
||||
var uri = base_url + 'getblockhash?height=' + height;
|
||||
request({uri: uri, json: true}, function (error, response, body) {
|
||||
return cb(body);
|
||||
});
|
||||
} else {
|
||||
client.command([{method:'getblockhash', parameters: [height]}], function(err, response){
|
||||
if(err){console.log('Error: ', err); onlyConsole.trace(err)}
|
||||
else{
|
||||
if(response[0].name == 'RpcError'){
|
||||
return cb('There was an error. Check your console.');
|
||||
}
|
||||
return cb(response[0]);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
get_block: function(hash, cb) {
|
||||
var uri = base_url + 'getblock?hash=' + hash;
|
||||
request({uri: uri, json: true, headers: {'User-Agent': 'eiquidus'}}, function (error, response, body) {
|
||||
return cb(body);
|
||||
});
|
||||
if (settings.use_rpc) {
|
||||
var uri = base_url + 'getblock?hash=' + hash;
|
||||
request({uri: uri, json: true}, function (error, response, body) {
|
||||
return cb(body);
|
||||
});
|
||||
} else {
|
||||
client.command([{method:'getblock', parameters: [hash]}], function(err, response){
|
||||
if(err){console.log('Error: ', err); onlyConsole.trace(err)}
|
||||
else{
|
||||
if(response[0].name == 'RpcError'){
|
||||
return cb('There was an error. Check your console.');
|
||||
}
|
||||
return cb(response[0]);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
get_rawtransaction: function(hash, cb) {
|
||||
|
||||
@@ -143,6 +143,7 @@ exports.check_timeout = 250;
|
||||
exports.genesis_tx = "dd1d332ad2d8d8f49195056d482ae3c96fd2d16e9d166413b27ca7f19775644c";
|
||||
exports.genesis_block = "0000860fcf946b44df0e7d85d6757d45f8de6f4c9aacc5c7b6abc13db1f68819";
|
||||
|
||||
exports.use_rpc = false;
|
||||
exports.heavy = false;
|
||||
exports.lock_during_index = false;
|
||||
exports.txcount = 100;
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
"check_timeout": 250,
|
||||
|
||||
// wallet settings
|
||||
"use_rpc": false,
|
||||
|
||||
"wallet": {
|
||||
"host": "localhost",
|
||||
"port": 51573,
|
||||
|
||||
Reference in New Issue
Block a user