diff --git a/lib/bcoin/block.js b/lib/bcoin/block.js index 5237661d..0aa0b8b7 100644 --- a/lib/bcoin/block.js +++ b/lib/bcoin/block.js @@ -41,8 +41,6 @@ function Block(data, subtype) { this.network = data.network || false; this.relayedBy = data.relayedBy || '0.0.0.0'; - this._height = data._height != null ? data._height : -1; - this._nextBlock = data._nextBlock || null; // List of matched TXs this.tx = []; @@ -61,14 +59,14 @@ function Block(data, subtype) { return tx; }); - if (this.version >= 2 && this._height === -1) { - tx = this.txs[0]; - if (tx && tx.inputs[0] && +tx.inputs[0].out.hash === 0) { - height = bcoin.script.coinbaseHeight(tx.inputs[0].script, this); - if (height > 0) - this._height = height; - } - } + // if (this.version >= 2 && this.height === -1) { + // tx = this.txs[0]; + // if (tx && tx.isCoinbase()) { + // height = bcoin.script.coinbaseHeight(tx.inputs[0].script, this); + // if (height > 0) + // this.height = height; + // } + // } this.invalid = !this._checkBlock(); } @@ -255,23 +253,17 @@ Block.prototype._checkBlock = function checkBlock() { }; Block.prototype.getHeight = function getHeight(chain) { - if (this._height >= 0) - return this._height; - chain = chain || bcoin.chain.global; if (!chain) return -1; - return this._height = chain.getHeight(this.hash('hex')); + return chain.getHeight(this.hash('hex')); }; Block.prototype.getNextBlock = function getNextBlock(chain) { var next; - if (this._nextBlock) - return this._nextBlock; - chain = chain || bcoin.chain.global; if (!chain) @@ -282,7 +274,7 @@ Block.prototype.getNextBlock = function getNextBlock(chain) { if (!next) return utils.toHex(constants.zeroHash); - return this._nextBlock = next; + return next; }; Block.reward = function reward(height) { @@ -343,10 +335,6 @@ Block.prototype.__defineGetter__('rhash', function() { return utils.revHex(this.hash('hex')); }); -Block.prototype.__defineSetter__('height', function(height) { - return this._height = height; -}); - Block.prototype.__defineGetter__('height', function() { return this.getHeight(bcoin.chain.global); }); @@ -387,7 +375,6 @@ Block.prototype.toJSON = function toJSON() { ts: this.ts, network: this.network, relayedBy: this.relayedBy, - _height: this._height, block: utils.toHex(bcoin.protocol.framer.block(this, this.subtype)) }; }; @@ -408,7 +395,6 @@ Block.fromJSON = function fromJSON(json) { data.network = json.network; data.relayedBy = json.relayedBy; - data._height = json._height; block = new Block(data, json.subtype); diff --git a/lib/bcoin/tx.js b/lib/bcoin/tx.js index 9efcf0cb..2bc8a4bd 100644 --- a/lib/bcoin/tx.js +++ b/lib/bcoin/tx.js @@ -36,8 +36,6 @@ function TX(data, block) { this.network = data.network || false; this.relayedBy = data.relayedBy || '0.0.0.0'; - this._height = data._height != null ? data._height : -1; - this._confirmations = data._confirmations != null ? data._confirmations : -1; this._lock = this.lock; @@ -838,25 +836,17 @@ TX.prototype.funds = function funds(side) { }; TX.prototype.getHeight = function getHeight(chain) { - if (this._height >= 0) - return this._height; - chain = chain || bcoin.chain.global; if (!chain) return -1; - this._height = this.block ? chain.getHeight(this.block) : -1; - - return this._height; + return this.block ? chain.getHeight(this.block) : -1; }; TX.prototype.getConfirmations = function getConfirmations(chain) { var top, height; - if (this._confirmations >= 0) - return this._confirmations; - chain = chain || bcoin.chain.global; if (!chain) @@ -889,10 +879,6 @@ TX.prototype.__defineGetter__('value', function() { return this.funds('in'); }); -TX.prototype.__defineSetter__('height', function(height) { - return this._height = height; -}); - TX.prototype.__defineGetter__('height', function() { return this.getHeight(bcoin.chain.global); });