Move to checkTxRoots and warn checkMerkleRoot deprecation

This commit is contained in:
junderw 2019-01-17 17:01:15 +09:00
parent 581ab5f136
commit e52abecee2
No known key found for this signature in database
GPG key ID: B256185D3A971908
4 changed files with 27 additions and 11 deletions

View file

@ -167,13 +167,22 @@ class Block {
toHex(headersOnly) {
return this.toBuffer(headersOnly).toString('hex');
}
checkTxRoots() {
return this.__checkMerkleRoot() &&
(this.hasWitnessCommit() ? this.__checkWitnessCommit() : true);
}
checkMerkleRoot() {
console.warn('Deprecation Warning: Block method checkMerkleRoot will be ' +
'deprecated in v5. Please use checkTxRoots instead.');
return this.checkTxRoots();
}
__checkMerkleRoot() {
if (!this.transactions)
throw errorMerkleNoTxes;
const actualMerkleRoot = Block.calculateMerkleRoot(this.transactions);
return this.merkleRoot.compare(actualMerkleRoot) === 0;
}
checkWitnessCommit() {
__checkWitnessCommit() {
if (!this.transactions)
throw errorMerkleNoTxes;
if (!this.hasWitnessCommit())