From 4484a11ede4adc18c02c59c4d25d9cca50bf7066 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 10 Dec 2016 07:18:05 -0800 Subject: [PATCH] tx/block: refactor. --- lib/primitives/block.js | 10 ++++++---- lib/primitives/input.js | 4 ++-- lib/primitives/mtx.js | 4 ++-- lib/primitives/tx.js | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/primitives/block.js b/lib/primitives/block.js index f609acf5..2faf9fd1 100644 --- a/lib/primitives/block.js +++ b/lib/primitives/block.js @@ -540,13 +540,15 @@ Block.prototype.getCoinbaseHeight = function getCoinbaseHeight() { */ Block.prototype.getReward = function getReward(view, network) { - var i, reward, fee; + var i, tx, reward, fee; network = Network.get(network); reward = btcutils.getReward(this.height, network.halvingInterval); for (i = 1; i < this.txs.length; i++) { - fee = this.txs[i].getFee(view); + tx = this.txs[i]; + + fee = tx.getFee(view); if (fee < 0 || fee > constants.MAX_MONEY) return -1; @@ -607,7 +609,7 @@ Block.prototype.getPrevout = function getPrevout() { */ Block.prototype.inspect = function inspect() { - return this.show(); + return this.format(); }; /** @@ -616,7 +618,7 @@ Block.prototype.inspect = function inspect() { * @returns {Object} */ -Block.prototype.show = function show(view) { +Block.prototype.format = function format(view) { var commitmentHash = this.getCommitmentHash('hex'); return { hash: this.rhash(), diff --git a/lib/primitives/input.js b/lib/primitives/input.js index 55e40909..5710c153 100644 --- a/lib/primitives/input.js +++ b/lib/primitives/input.js @@ -225,7 +225,7 @@ Input.prototype.isCoinbase = function isCoinbase() { */ Input.prototype.inspect = function inspect() { - return this.show(); + return this.format(); }; /** @@ -233,7 +233,7 @@ Input.prototype.inspect = function inspect() { * @returns {Object} */ -Input.prototype.show = function show(coin) { +Input.prototype.format = function format(coin) { return { type: this.getType(coin), subtype: this.getSubtype(coin), diff --git a/lib/primitives/mtx.js b/lib/primitives/mtx.js index 41aeb9b2..37e85015 100644 --- a/lib/primitives/mtx.js +++ b/lib/primitives/mtx.js @@ -1329,7 +1329,7 @@ MTX.prototype._mutable = function _mutable() { */ MTX.prototype.inspect = function inspect() { - return this.show(); + return this.format(); }; /** @@ -1337,7 +1337,7 @@ MTX.prototype.inspect = function inspect() { * @returns {Object} */ -MTX.prototype.show = function show() { +MTX.prototype.format = function format() { return TX.prototype.inspect.call(this, this.view); }; diff --git a/lib/primitives/tx.js b/lib/primitives/tx.js index 1cbd06e1..55cba977 100644 --- a/lib/primitives/tx.js +++ b/lib/primitives/tx.js @@ -2002,7 +2002,7 @@ TX.prototype.toInv = function toInv() { */ TX.prototype.inspect = function inspect() { - return this.show(); + return this.format(); }; /** @@ -2011,7 +2011,7 @@ TX.prototype.inspect = function inspect() { * @returns {Object} */ -TX.prototype.show = function show(view) { +TX.prototype.format = function format(view) { var rate = 0; var fee = 0;