block: remove commitment hash cache.
This commit is contained in:
parent
f71f2d954b
commit
426ab85f15
@ -38,7 +38,6 @@ function Block(options) {
|
||||
this.txs = [];
|
||||
|
||||
this._cbHeight = null;
|
||||
this._commitmentHash = null;
|
||||
|
||||
this._raw = null;
|
||||
this._size = -1;
|
||||
@ -400,32 +399,23 @@ Block.prototype.getWitnessNonce = function getWitnessNonce() {
|
||||
*/
|
||||
|
||||
Block.prototype.getCommitmentHash = function getCommitmentHash(enc) {
|
||||
var hash = this._commitmentHash;
|
||||
var i, coinbase, output;
|
||||
var coinbase = this.txs[0];
|
||||
var i, hash, output;
|
||||
|
||||
if (!hash) {
|
||||
coinbase = this.txs[0];
|
||||
if (!coinbase)
|
||||
return null;
|
||||
|
||||
if (!coinbase)
|
||||
return null;
|
||||
|
||||
for (i = coinbase.outputs.length - 1; i >= 0; i--) {
|
||||
output = coinbase.outputs[i];
|
||||
|
||||
if (output.script.isCommitment()) {
|
||||
hash = output.script.getCommitmentHash();
|
||||
|
||||
if (!this.mutable)
|
||||
this._commitmentHash = hash;
|
||||
|
||||
break;
|
||||
}
|
||||
for (i = coinbase.outputs.length - 1; i >= 0; i--) {
|
||||
output = coinbase.outputs[i];
|
||||
if (output.script.isCommitment()) {
|
||||
hash = output.script.getCommitmentHash();
|
||||
break;
|
||||
}
|
||||
|
||||
if (!hash)
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!hash)
|
||||
return null;
|
||||
|
||||
return enc === 'hex'
|
||||
? hash.toString('hex')
|
||||
: hash;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user