tx/block: refactor.

This commit is contained in:
Christopher Jeffrey 2016-12-10 07:18:05 -08:00
parent c9523d91a5
commit 4484a11ede
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
4 changed files with 12 additions and 10 deletions

View File

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

View File

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

View File

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

View File

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