tx/block: refactor.
This commit is contained in:
parent
c9523d91a5
commit
4484a11ede
@ -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(),
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user