walletdb: minor.
This commit is contained in:
parent
d194f3b5d0
commit
de178092f1
@ -115,7 +115,7 @@ var layout = {
|
||||
},
|
||||
ee: function ee(key) {
|
||||
return key.toString('hex', 1);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
if (utils.isBrowser)
|
||||
@ -391,9 +391,9 @@ WalletDB.prototype.loadFilter = co(function* loadFilter() {
|
||||
});
|
||||
|
||||
/**
|
||||
* Test the bloom filter against an array of address hashes.
|
||||
* Test the bloom filter against a tx or address hash.
|
||||
* @private
|
||||
* @param {Hash[]} hashes
|
||||
* @param {Hash} hash
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
|
||||
@ -404,6 +404,19 @@ WalletDB.prototype.testFilter = function testFilter(hash) {
|
||||
return this.filter.test(hash, 'hex');
|
||||
};
|
||||
|
||||
/**
|
||||
* Add hash to filter.
|
||||
* @private
|
||||
* @param {Hash} hash
|
||||
*/
|
||||
|
||||
WalletDB.prototype.addFilter = function addFilter(hash) {
|
||||
if (!this.filter)
|
||||
return;
|
||||
|
||||
return this.filter.add(hash, 'hex');
|
||||
};
|
||||
|
||||
/**
|
||||
* Dump database (for debugging).
|
||||
* @returns {Promise} - Returns Object.
|
||||
@ -850,8 +863,7 @@ WalletDB.prototype.savePath = co(function* savePath(wallet, path) {
|
||||
var batch = this.batch(wallet);
|
||||
var wallets, result;
|
||||
|
||||
if (this.filter)
|
||||
this.filter.add(hash, 'hex');
|
||||
this.addFilter(hash);
|
||||
|
||||
this.emit('path', path);
|
||||
|
||||
@ -1448,7 +1460,7 @@ WalletDB.prototype._addBlock = co(function* addBlock(entry, txs) {
|
||||
|
||||
hash = tx.hash('hex');
|
||||
|
||||
this.filter.add(hash, 'hex');
|
||||
this.addFilter(hash);
|
||||
|
||||
block.hashes.push(hash);
|
||||
matches.push(wallets);
|
||||
@ -1552,7 +1564,7 @@ WalletDB.prototype._addTX = co(function* addTX(tx) {
|
||||
|
||||
yield this.db.put(layout.e(hash), serializeWallets(wallets));
|
||||
|
||||
this.filter.add(hash, 'hex');
|
||||
this.addFilter(hash);
|
||||
|
||||
return wallets;
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user