From 4eb31758e471952a12f76f6d90309b4839ef7fac Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Fri, 30 May 2014 13:14:53 -0300 Subject: [PATCH 1/2] fix double spent reports --- dev-util/getTx.js | 21 +++++++++++++++++++++ dev-util/get_tx.js | 27 --------------------------- lib/TransactionDb.js | 13 +++++++++---- 3 files changed, 30 insertions(+), 31 deletions(-) create mode 100755 dev-util/getTx.js delete mode 100755 dev-util/get_tx.js diff --git a/dev-util/getTx.js b/dev-util/getTx.js new file mode 100755 index 000000000..2a0ac8388 --- /dev/null +++ b/dev-util/getTx.js @@ -0,0 +1,21 @@ +#!/usr/bin/env node +'use strict'; + +var util = require('util'), + config = require('../config/config'); + +process.env.NODE_ENV = process.env.NODE_ENV || 'development'; + +var TransactionDb = require('../lib/TransactionDb.js').default(); +var hash = process.argv[2] || '4286d6fc82a314348af4e9d3ce649f78ce4569937e9ad6613563755f0d14e3d1'; + +var t= TransactionDb.fromIdWithInfo(hash,function(err,tx) { + console.log('Err:'); + console.log(err); + + console.log('Ret:'); + console.log(util.inspect(tx,{depth:null})); +}); + + + diff --git a/dev-util/get_tx.js b/dev-util/get_tx.js deleted file mode 100755 index 391747224..000000000 --- a/dev-util/get_tx.js +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env node -'use strict'; - -var util = require('util'); -var T = require('../lib/TransactionDb'); - -process.env.NODE_ENV = process.env.NODE_ENV || 'development'; - - -// var hash = process.argv[2] || '0000000000b6288775bbd326bedf324ca8717a15191da58391535408205aada4'; -var hash = process.argv[2] || 'e2253359458db3e732c82a43fc62f56979ff59928f25a2df34dfa443e9a41160'; - - - -var t = new T(); -t.fromIdWithInfo(hash, function(err, ret) { - - console.log('Err:'); - console.log(err); - - - console.log('Ret:'); - console.log(util.inspect(ret,{depth:null})); -}); - - - diff --git a/lib/TransactionDb.js b/lib/TransactionDb.js index 8b52e916d..afb8153d6 100644 --- a/lib/TransactionDb.js +++ b/lib/TransactionDb.js @@ -40,7 +40,7 @@ var bitcore = require('bitcore'), buffertools = require('buffertools'); var logger = require('./logger').logger; -var info = logger.info; +var inf = logger.inf; var db = imports.db || levelup(config.leveldb + '/txs',{maxOpenFiles: MAX_OPEN_FILES} ); var PoolMatch = imports.poolMatch || require('soop').load('./PoolMatch',config); @@ -188,7 +188,7 @@ TransactionDb.prototype._fillOutpoints = function(txInfo, cb) { async.eachLimit(txInfo.vin, CONCURRENCY, function(i, c_in) { self.fromTxIdN(i.txid, i.vout, function(err, ret) { if (!ret || !ret.addr || !ret.valueSat) { - info('Could not get TXouts in %s,%d from %s ', i.txid, i.vout, txInfo.txid); + inf('Could not get TXouts in %s,%d from %s ', i.txid, i.vout, txInfo.txid); if (ret) i.unconfirmedInput = ret.unconfirmedInput; incompleteInputs = 1; return c_in(); // error not scalated @@ -201,12 +201,15 @@ TransactionDb.prototype._fillOutpoints = function(txInfo, cb) { i.value = ret.valueSat / util.COIN; valueIn += i.valueSat; +console.log('[TransactionDb.js.204:ret:]',ret); //TODO if (ret.multipleSpentAttempt || !ret.spentTxId || - (ret.spentTxId && ret.spentTxId !== info.txid) + (ret.spentTxId && ret.spentTxId !== txInfo.txid) ) { if (ret.multipleSpentAttempts) { ret.multipleSpentAttempts.forEach(function(mul) { - if (mul.spentTxId !== info.txid) { + if (mul.spentTxId !== txInfo.txid) { + +console.log('[TransactionDb.js.210]'); //TODO i.doubleSpentTxID = ret.spentTxId; i.doubleSpentIndex = ret.spentIndex; } @@ -214,6 +217,8 @@ TransactionDb.prototype._fillOutpoints = function(txInfo, cb) { } else if (!ret.spentTxId) { i.dbError = 'Input spent not registered'; } else { + +console.log('[TransactionDb.js.219]'); //TODO i.doubleSpentTxID = ret.spentTxId; i.doubleSpentIndex = ret.spentIndex; } From 69f7ee6aa72f0c14f7d4026ef312907e3b8c0bec Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Fri, 30 May 2014 13:20:19 -0300 Subject: [PATCH 2/2] remove console logs --- app/controllers/blocks.js | 5 ----- lib/BlockDb.js | 1 - 2 files changed, 6 deletions(-) diff --git a/app/controllers/blocks.js b/app/controllers/blocks.js index 955fbdb0a..2de390d4f 100644 --- a/app/controllers/blocks.js +++ b/app/controllers/blocks.js @@ -100,7 +100,6 @@ exports.list = function(req, res) { var dateStr; var todayStr = formatTimestamp(new Date()); -console.log('[blocks.js.102]'); //TODO if (req.query.blockDate) { // TODO: Validate format yyyy-mm-dd dateStr = req.query.blockDate; @@ -110,18 +109,14 @@ console.log('[blocks.js.102]'); //TODO isToday = true; } var gte = Math.round((new Date(dateStr)).getTime() / 1000); -console.log('[blocks.js.112:gte:]',gte); //TODO //pagination var lte = parseInt(req.query.startTimestamp) || gte + 86400; -console.log('[blocks.js.115:lte:]',lte); //TODO var prev = formatTimestamp(new Date((gte - 86400) * 1000)); var next = lte ? formatTimestamp(new Date(lte * 1000)) :null; -console.log('[blocks.js.116:next:]',next, lte); //TODO var limit = parseInt(req.query.limit || DFLT_LIMIT) + 1; var more; -console.log('[blocks.js.119]'); //TODO bdb.getBlocksByDate(gte, lte, limit, function(err, blockList) { if (err) { diff --git a/lib/BlockDb.js b/lib/BlockDb.js index a90ac2e44..04b5f1c1b 100644 --- a/lib/BlockDb.js +++ b/lib/BlockDb.js @@ -301,7 +301,6 @@ BlockDb.prototype.getBlocksByDate = function(start_ts, end_ts, limit, cb) { limit: limit, reverse: 1, }; -console.log('[BlockDb.js.298:opts:]',opts); //TODO db.createReadStream(opts) .on('data', function (data) {