From b3f36c3e72d3ec8a48a9ed4002fd86664f8b2c50 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Wed, 8 Jan 2014 15:25:49 -0300 Subject: [PATCH] various small changes to bitcore --- Block.js | 2 +- Connection.js | 2 +- Transaction.js | 2 +- const.js | 13 ++++++++++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Block.js b/Block.js index 5cae78be9..9efa15ffa 100644 --- a/Block.js +++ b/Block.js @@ -64,7 +64,7 @@ function spec(b) { var txCount = parser.varInt(); - for (i = 0; i < txCount; i++) { + for (var i = 0; i < txCount; i++) { var tx = new Transaction(); tx.parse(parser); this.txs.push(tx); diff --git a/Connection.js b/Connection.js index a50edb50d..3558b150e 100644 --- a/Connection.js +++ b/Connection.js @@ -476,7 +476,7 @@ function spec(b) { lock_time: tx.lock_time, ins: tx.ins, outs: tx.outs, - tx: tx, + tx: tx, }; case 'getblocks': diff --git a/Transaction.js b/Transaction.js index 205ffc5a6..0cc95bbd9 100644 --- a/Transaction.js +++ b/Transaction.js @@ -553,7 +553,7 @@ function spec(b) { var ins = this.ins.map(function (txin) { var txinObj = { prev_out: { - hash: new Buffer(txin.getOutpointHash()).reverse().toString(hex), + hash: new Buffer(txin.getOutpointHash()).reverse().toString('hex'), n: txin.getOutpointIndex() } }; diff --git a/const.js b/const.js index cd6a77e9a..9edf459ea 100644 --- a/const.js +++ b/const.js @@ -1,7 +1,18 @@ -exports.MSG = { +MSG = { TX: 1, BLOCK: 2, FILTERED_BLOCK: 3, }; +MSG.to_str = function(t) { + switch(t) { + case MSG.TX: return 'transaction'; + case MSG.BLOCK: return 'block'; + case MSG.FILTERED_BLOCK: return 'filtered block'; + default: return 'unknown'; + } +} + +exports.MSG = MSG; +