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. * Module dependencies.
*/ */
var Transaction = require('../../lib/TransactionDb').class();
var Address = require('../models/Address'); var Address = require('../models/Address');
var async = require('async'); var async = require('async');
var common = require('./common'); var common = require('./common');
var TransactionDb = require('../../lib/TransactionDb').class();
var BlockDb = require('../../lib/BlockDb').class(); var BlockDb = require('../../lib/BlockDb').class();
var bdb = new BlockDb(); var bdb = new BlockDb();
@ -17,7 +17,9 @@ var bdb = new BlockDb();
* Find transaction by hash ... * Find transaction by hash ...
*/ */
exports.transaction = function(req, res, next, txid) { 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) if (err || ! tx)
return common.handleErrors(err, res); return common.handleErrors(err, res);
else { else {
@ -40,7 +42,9 @@ exports.show = function(req, res) {
var getTransaction = function(txid, cb) { var getTransaction = function(txid, cb) {
Transaction.fromIdWithInfo(txid, function(err, tx) { var tDb = new TransactionDb();
tDb.fromIdWithInfo(txid, function(err, tx) {
if (err) { if (err) {
console.log(err); console.log(err);
} }

View File

@ -9,8 +9,7 @@ function spec() {
var BitcoreUtil = require('bitcore/util/util'); var BitcoreUtil = require('bitcore/util/util');
var TransactionDb = require('../../lib/TransactionDb').class(); var TransactionDb = require('../../lib/TransactionDb').class();
function Address(addrStr, txDb) { function Address(addrStr) {
this.txDb = txDb || new TransactionDb();
this.balanceSat = 0; this.balanceSat = 0;
this.totalReceivedSat = 0; this.totalReceivedSat = 0;
this.totalSentSat = 0; this.totalSentSat = 0;
@ -57,9 +56,10 @@ function spec() {
Address.prototype.update = function(next) { Address.prototype.update = function(next) {
var self = this; var self = this;
var db = new TransactionDb();
async.series([ async.series([
function (cb) { function (cb) {
self.txDb.fromAddr(self.addrStr, function(err,txOut){ db.fromAddr(self.addrStr, function(err,txOut){
if (err) return cb(err); if (err) return cb(err);
txOut.forEach(function(txItem){ txOut.forEach(function(txItem){

View File

@ -137,6 +137,7 @@ function spec(b) {
limit: parseInt(limit) // force to int limit: parseInt(limit) // force to int
}) })
.on('data', function (data) { .on('data', function (data) {
console.log('[BlockDb.js.137:data:]',data); //TODO
list.push({ list.push({
ts: data.key.replace(TIMESTAMP_ROOT, ''), ts: data.key.replace(TIMESTAMP_ROOT, ''),
hash: data.value, hash: data.value,