more cleaning up

This commit is contained in:
tenthirtyone 2017-08-22 00:29:10 -04:00
parent e5ad52f55d
commit c2c51e709a
7 changed files with 13 additions and 17 deletions

View File

@ -28,7 +28,7 @@ const config = {
ticker_url: 'https://www.bitstamp.net/api/ticker/',
ticker_prop: 'bitstamp',
max_blocks: 72,
max_txs: 50,
max_txs: 10,
max_page_txs: 10,
request_ttl: 100000,
},

View File

@ -1,12 +1,7 @@
const logger = require('../logger');
const request = require('request');
const config = require('../../config');
const util = require('../util');
const db = require('../db');
const API_URL = `http://${config.bcoin_http}:${config.bcoin['http-port']}`;
const TTL = config.api.request_ttl;
module.exports = function AddressAPI(router) {
router.get('/addr/:addr', (req, res) => {
const addr = req.params.addr || '';

View File

@ -97,12 +97,12 @@ module.exports = function statusAPI(router) {
});
// Copied from previous source
router.get('/peer', (req, res) => res.json({
connected: true,
host: '127.0.0.1',
port: null,
}));
connected: true,
host: '127.0.0.1',
port: null,
}));
router.get('/version', (req, res) => res.json({
version: pkg.version,
}));
version: pkg.version,
}));
};

View File

@ -2,7 +2,8 @@ const mongoose = require('mongoose');
const config = require('../config');
const Schema = mongoose.Schema;
const MAX_BLOCKS = config.api.max_blocks; // ~ 12 hours
// These limits can be overriden higher up the stack
const MAX_BLOCKS = config.api.max_blocks;
const BlockSchema = new Schema({
hash: { type: String, default: '' },

View File

@ -11,8 +11,6 @@ const InputSchema = new Schema({
address: { type: String, default: '' },
});
InputSchema.index({ address: 1 });
const Input = mongoose.model('Input', InputSchema);
module.exports = Input;

View File

@ -9,8 +9,6 @@ const OutputSchema = new Schema({
type: { type: String, default: '' },
});
OutputSchema.index({ address: 1 });
const Output = mongoose.model('Output', OutputSchema);
module.exports = Output;

View File

@ -5,6 +5,7 @@ const logger = require('../lib/logger');
const config = require('../config');
const Schema = mongoose.Schema;
// These limits can be overriden higher up the stack
const MAX_TXS = config.api.max_txs;
const MAX_PAGE_TXS = config.api.max_page_txs;
@ -27,6 +28,9 @@ const TransactionSchema = new Schema({
});
TransactionSchema.index({ hash: 1 });
TransactionSchema.index({ 'outputs.address': 1 });
TransactionSchema.index({ 'inputs.address': 1 });
TransactionSchema.methods.byId = function txById(txid, cb) {
return this.model('Transaction').findOne(