Merge branch 'feature/leveldb' of github.com:matiu/insight into feature/leveldb

This commit is contained in:
Gustavo Cortez 2014-02-05 15:12:05 -03:00
commit 318d52d593
3 changed files with 11 additions and 6 deletions

View File

@ -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);
}

View File

@ -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){

View File

@ -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,