From a5528e49d8b2b6957a4587dbf52045608c7e6e42 Mon Sep 17 00:00:00 2001 From: tenthirtyone Date: Thu, 3 Aug 2017 21:45:35 -0400 Subject: [PATCH] db connection moved to index.js to be a little more explicit. Cleaned up some comments and console logs --- index.js | 3 +++ lib/db/index.js | 3 --- lib/node/index.js | 9 --------- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/index.js b/index.js index 559a8b9..b060e0a 100644 --- a/index.js +++ b/index.js @@ -2,10 +2,13 @@ const node = require('./lib/node'); const config = require('./config/config'); const logger = require('./lib/logger'); const Api = require('./lib/api'); +const db = require('./lib/db'); logger.log('debug', 'Debug mode started'); +db.connect(config.mongodb.uri, config.mongodb.options); + Api.listen(config.api.port, () => { logger.log('debug', 'listening on port 3000'); diff --git a/lib/db/index.js b/lib/db/index.js index cce9817..e6cb4c9 100644 --- a/lib/db/index.js +++ b/lib/db/index.js @@ -1,6 +1,3 @@ const mongoose = require('mongoose'); -const config = require('../../config/config'); - -mongoose.connect(config.mongodb.uri, config.mongodb.options); module.exports = mongoose; diff --git a/lib/node/index.js b/lib/node/index.js index 4b78401..19729ca 100644 --- a/lib/node/index.js +++ b/lib/node/index.js @@ -2,7 +2,6 @@ const FullNode = require('bcoin/lib/node/fullnode'); const config = require('../../config/config'); const node = new FullNode(config.bcoin); const logger = require('../../lib/logger'); -const db = require('../../lib/db'); const util = require('../../lib/util'); const BlockModel = require('../../models/block'); const TxModel = require('../../models/transaction').Transaction; @@ -97,20 +96,12 @@ function processTx(entry, txs) { fees: tx.fee, chain: config.bcoin.network, }); - console.log(txHash); t.save((err) => { if (err) { console.log(err.message); } }); }); - - // console.log(util.revHex(tx.hash().toString('hex'))); - // tx.hash = util.revHex(tx.hash().toString('hex')); - // entry.hash = util.revHex(entry.hash().toString('hex')); - /* - - */ } module.exports = {