indexes and experimenting with mem db

This commit is contained in:
tenthirtyone 2017-08-16 21:23:29 -04:00
parent 2ac70bc9a2
commit 1cb0a6b385
6 changed files with 10 additions and 2 deletions

View File

@ -4,7 +4,7 @@ const config = {
bcoin_http: 'localhost', bcoin_http: 'localhost',
bcoin: { bcoin: {
network: 'main', network: 'main',
db: 'leveldb', db: 'mem',
prefix: '.', prefix: '.',
checkpoints: true, checkpoints: true,
workers: false, workers: false,

View File

@ -8,6 +8,8 @@ const TTL = config.api.request_ttl;
module.exports = function AddressAPI(router) { module.exports = function AddressAPI(router) {
router.get('/addr/:addr', (req, res) => { router.get('/addr/:addr', (req, res) => {
const addr = req.params.addr || ''; const addr = req.params.addr || '';
logger.log('debug',
'Warning: Requesting data from Bcoin by address, may take some time');
// Get Bcoin data // Get Bcoin data
return request(`${API_URL}/tx/address/${addr}`, return request(`${API_URL}/tx/address/${addr}`,
{ timeout: TTL }, { timeout: TTL },

View File

@ -147,7 +147,7 @@ module.exports = function transactionAPI(router) {
const addr = req.query.address || ''; const addr = req.query.address || '';
logger.log('debug', logger.log('debug',
'Warning: Requesting data from Bcoin, may take some time'); 'Warning: Requesting data from Bcoin by address, may take some time');
return request(`${API_URL}/tx/address/${addr}`, return request(`${API_URL}/tx/address/${addr}`,
{ timeout: TTL }, { timeout: TTL },

View File

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

View File

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

View File

@ -22,6 +22,8 @@ const TransactionSchema = new Schema({
network: { type: String, default: '' }, network: { type: String, default: '' },
}); });
TransactionSchema.index({ hash: 1 });
const Transaction = mongoose.model('Transaction', TransactionSchema); const Transaction = mongoose.model('Transaction', TransactionSchema);
module.exports = Transaction; module.exports = Transaction;