diff --git a/app/controllers/transactions.js b/app/controllers/transactions.js index 9eeb5f14..e69b76de 100644 --- a/app/controllers/transactions.js +++ b/app/controllers/transactions.js @@ -3,11 +3,11 @@ /** * Module dependencies. */ -var Transaction = require('../../lib/TransactionDb').class(); var Address = require('../models/Address'); var async = require('async'); var common = require('./common'); +var TransactionDb = require('../../lib/TransactionDb').class(); var BlockDb = require('../../lib/BlockDb').class(); var bdb = new BlockDb(); @@ -17,7 +17,9 @@ var bdb = new BlockDb(); * Find transaction by hash ... */ exports.transaction = function(req, res, next, txid) { - Transaction.fromIdWithInfo(txid, function(err, tx) { + var tDb = new TransactionDb(); + + tDb.fromIdWithInfo(txid, function(err, tx) { if (err || ! tx) return common.handleErrors(err, res); else { @@ -40,7 +42,9 @@ exports.show = function(req, res) { var getTransaction = function(txid, cb) { - Transaction.fromIdWithInfo(txid, function(err, tx) { + var tDb = new TransactionDb(); + + tDb.fromIdWithInfo(txid, function(err, tx) { if (err) { console.log(err); } diff --git a/app/models/Address.js b/app/models/Address.js index 8dc62861..97e05271 100644 --- a/app/models/Address.js +++ b/app/models/Address.js @@ -9,8 +9,7 @@ function spec() { var BitcoreUtil = require('bitcore/util/util'); var TransactionDb = require('../../lib/TransactionDb').class(); - function Address(addrStr, txDb) { - this.txDb = txDb || new TransactionDb(); + function Address(addrStr) { this.balanceSat = 0; this.totalReceivedSat = 0; this.totalSentSat = 0; @@ -57,9 +56,10 @@ function spec() { Address.prototype.update = function(next) { var self = this; + var db = new TransactionDb(); async.series([ function (cb) { - self.txDb.fromAddr(self.addrStr, function(err,txOut){ + db.fromAddr(self.addrStr, function(err,txOut){ if (err) return cb(err); txOut.forEach(function(txItem){ diff --git a/lib/BlockDb.js b/lib/BlockDb.js index c70279f2..a64ae665 100644 --- a/lib/BlockDb.js +++ b/lib/BlockDb.js @@ -137,6 +137,7 @@ function spec(b) { limit: parseInt(limit) // force to int }) .on('data', function (data) { +console.log('[BlockDb.js.137:data:]',data); //TODO list.push({ ts: data.key.replace(TIMESTAMP_ROOT, ''), hash: data.value,