Move to checkTxRoots and warn checkMerkleRoot deprecation
This commit is contained in:
parent
581ab5f136
commit
e52abecee2
4 changed files with 27 additions and 11 deletions
src
11
src/block.js
11
src/block.js
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue