moved rpc settings to config. Little confusing as is. Needs improvement
This commit is contained in:
parent
b1e540c8df
commit
4b71ae91ae
@ -1,6 +1,7 @@
|
|||||||
const config = {
|
const config = {
|
||||||
start_node: true,
|
start_node: true,
|
||||||
logging: 'debug',
|
logging: 'debug',
|
||||||
|
bcoin_http: 'localhost',
|
||||||
bcoin: {
|
bcoin: {
|
||||||
network: 'main',
|
network: 'main',
|
||||||
db: 'leveldb',
|
db: 'leveldb',
|
||||||
@ -12,6 +13,7 @@ const config = {
|
|||||||
'max-outbound': 10,
|
'max-outbound': 10,
|
||||||
'index-tx': true,
|
'index-tx': true,
|
||||||
'index-address': true,
|
'index-address': true,
|
||||||
|
'http-port': 8332,
|
||||||
},
|
},
|
||||||
mongodb: {
|
mongodb: {
|
||||||
uri: 'mongodb://localhost/bitcore',
|
uri: 'mongodb://localhost/bitcore',
|
||||||
|
|||||||
@ -2,6 +2,7 @@ const Block = require('../../models/block.js');
|
|||||||
const Transaction = require('../../models/transaction');
|
const Transaction = require('../../models/transaction');
|
||||||
const logger = require('../logger');
|
const logger = require('../logger');
|
||||||
const request = require('request');
|
const request = require('request');
|
||||||
|
const config = require('../../config');
|
||||||
|
|
||||||
const MAX_TXS = 20;
|
const MAX_TXS = 20;
|
||||||
const MAX_BLOCKS = 1;
|
const MAX_BLOCKS = 1;
|
||||||
@ -40,7 +41,7 @@ function getTransactions(params, options, cb) {
|
|||||||
|
|
||||||
module.exports = function transactionAPI(router) {
|
module.exports = function transactionAPI(router) {
|
||||||
router.get('/tx/:txid', (req, res) => {
|
router.get('/tx/:txid', (req, res) => {
|
||||||
request(`http://localhost:8332/tx/${req.params.txid}`, (err, localRes, body) => {
|
request(`http://${config.bcoin_http}:${config.bcoin['http-port']}/tx/${req.params.txid}`, (err, localRes, body) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
logger.log('error',
|
logger.log('error',
|
||||||
`${err}`);
|
`${err}`);
|
||||||
@ -77,7 +78,7 @@ module.exports = function transactionAPI(router) {
|
|||||||
|
|
||||||
router.get('/txs', (req, res) => {
|
router.get('/txs', (req, res) => {
|
||||||
if (req.query.block) {
|
if (req.query.block) {
|
||||||
request(`http://localhost:8332/block/${req.query.block}`, (err, localRes, body) => {
|
request(`http://${config.bcoin_http}:${config.bcoin['http-port']}/block/${req.query.block}`, (err, localRes, body) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
logger.log('error',
|
logger.log('error',
|
||||||
`${err}`);
|
`${err}`);
|
||||||
@ -109,7 +110,7 @@ module.exports = function transactionAPI(router) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else if (req.query.address) {
|
} else if (req.query.address) {
|
||||||
request(`http://localhost:8332/tx/address/${req.query.address}`, (err, localRes, body) => {
|
request(`http://${config.bcoin_http}:${config.bcoin['http-port']}/tx/address/${req.query.address}`, (err, localRes, body) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
logger.log('error',
|
logger.log('error',
|
||||||
`${err}`);
|
`${err}`);
|
||||||
@ -120,7 +121,6 @@ module.exports = function transactionAPI(router) {
|
|||||||
logger.log('error',
|
logger.log('error',
|
||||||
`${err}`);
|
`${err}`);
|
||||||
}
|
}
|
||||||
console.log(body);
|
|
||||||
res.send({
|
res.send({
|
||||||
pagesTotal: 1,
|
pagesTotal: 1,
|
||||||
txs: body.map(tx => ({
|
txs: body.map(tx => ({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user