consistency. chain test.

This commit is contained in:
Christopher Jeffrey 2016-05-31 22:16:15 -07:00
parent 293f9c5dc5
commit 0c4df11cb6
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
3 changed files with 14 additions and 14 deletions

View File

@ -361,11 +361,11 @@ MerkleBlock.fromRaw = function fromRaw(data, enc) {
* it through a filter first. This will build the partial * it through a filter first. This will build the partial
* merkle tree. * merkle tree.
* @param {Block} block * @param {Block} block
* @param {Bloom} bloom * @param {Bloom} filter
* @returns {MerkleBlock} * @returns {MerkleBlock}
*/ */
MerkleBlock.fromBlock = function fromBlock(block, bloom) { MerkleBlock.fromBlock = function fromBlock(block, filter) {
var matches = []; var matches = [];
var txs = []; var txs = [];
var leaves = []; var leaves = [];
@ -375,7 +375,7 @@ MerkleBlock.fromBlock = function fromBlock(block, bloom) {
for (i = 0; i < block.txs.length; i++) { for (i = 0; i < block.txs.length; i++) {
tx = block.txs[i]; tx = block.txs[i];
if (tx.isWatched(bloom)) { if (tx.isWatched(filter)) {
matches.push(1); matches.push(1);
txs.push(tx); txs.push(tx);
} else { } else {

View File

@ -1604,14 +1604,14 @@ TX.prototype.getPrevout = function getPrevout() {
* value is. * value is.
* @see "Filter matching algorithm": * @see "Filter matching algorithm":
* @see https://github.com/bitcoin/bips/blob/master/bip-0037.mediawiki * @see https://github.com/bitcoin/bips/blob/master/bip-0037.mediawiki
* @param {Bloom} bloom * @param {Bloom} filter
* @returns {Boolean} True if the transaction matched. * @returns {Boolean} True if the transaction matched.
*/ */
TX.prototype.isWatched = function isWatched(bloom) { TX.prototype.isWatched = function isWatched(filter) {
var i, input, output, hash, index, outpoint; var i, input, output, hash, index, outpoint;
if (!bloom) if (!filter)
return false; return false;
function testScript(code) { function testScript(code) {
@ -1623,7 +1623,7 @@ TX.prototype.isWatched = function isWatched(bloom) {
break; break;
if (!Buffer.isBuffer(chunk) || chunk.length === 0) if (!Buffer.isBuffer(chunk) || chunk.length === 0)
continue; continue;
if (bloom.test(chunk)) if (filter.test(chunk))
return true; return true;
} }
@ -1631,7 +1631,7 @@ TX.prototype.isWatched = function isWatched(bloom) {
} }
// 1. Test the tx hash // 1. Test the tx hash
if (bloom.test(this.hash())) if (filter.test(this.hash()))
return true; return true;
// 2. Test data elements in output scripts // 2. Test data elements in output scripts
@ -1640,13 +1640,13 @@ TX.prototype.isWatched = function isWatched(bloom) {
output = this.outputs[i]; output = this.outputs[i];
// Test the output script // Test the output script
if (testScript(output.script.code)) { if (testScript(output.script.code)) {
if (bloom.update === constants.filterFlags.ALL) { if (filter.update === constants.filterFlags.ALL) {
outpoint = bcoin.protocol.framer.outpoint(this.hash(), i); outpoint = bcoin.protocol.framer.outpoint(this.hash(), i);
bloom.add(outpoint); filter.add(outpoint);
} else if (bloom.update === constants.filterFlags.PUBKEY_ONLY) { } else if (filter.update === constants.filterFlags.PUBKEY_ONLY) {
if (output.script.isPubkey() || output.script.isMultisig()) { if (output.script.isPubkey() || output.script.isMultisig()) {
outpoint = bcoin.protocol.framer.outpoint(this.hash(), i); outpoint = bcoin.protocol.framer.outpoint(this.hash(), i);
bloom.add(outpoint); filter.add(outpoint);
} }
} }
return true; return true;
@ -1662,7 +1662,7 @@ TX.prototype.isWatched = function isWatched(bloom) {
outpoint = bcoin.protocol.framer.outpoint(hash, index); outpoint = bcoin.protocol.framer.outpoint(hash, index);
// Test the COutPoint structure // Test the COutPoint structure
if (bloom.test(outpoint)) if (filter.test(outpoint))
return true; return true;
// Test the input script // Test the input script

View File

@ -40,7 +40,7 @@ describe('Chain', function() {
value: utils.satoshi('25.0') value: utils.satoshi('25.0')
}); });
redeemer.addOutput({ redeemer.addOutput({
address: wallet.deriveAddress(false, 100).getAddress(), address: wallet.account.deriveAddress(false, 100).getAddress(),
value: utils.satoshi('5.0') value: utils.satoshi('5.0')
}); });
redeemer.addInput(tx, 0); redeemer.addInput(tx, 0);