diff --git a/lib/bcoin/lowlevelup.js b/lib/bcoin/lowlevelup.js index 2308c84c..cf3bccd0 100644 --- a/lib/bcoin/lowlevelup.js +++ b/lib/bcoin/lowlevelup.js @@ -237,9 +237,9 @@ LowlevelUp.prototype.fetch = function fetch(key, parse, callback) { LowlevelUp.prototype.iterate = function iterate(options, callback) { var items = []; - var iter; + var iter, opt; - options = { + opt = { gte: options.gte, lte: options.lte, keys: true, @@ -250,22 +250,22 @@ LowlevelUp.prototype.iterate = function iterate(options, callback) { reverse: options.reverse }; - if (options.gte == null) - delete options.gte; + if (opt.gte == null) + delete opt.gte; - if (options.lte == null) - delete options.lte; + if (opt.lte == null) + delete opt.lte; - if (options.values == null) - delete options.values; + if (opt.values == null) + delete opt.values; - if (options.limit == null) - delete options.limit; + if (opt.limit == null) + delete opt.limit; - if (options.reverse == null) - delete options.reverse; + if (opt.reverse == null) + delete opt.reverse; - iter = this.iterator(options); + iter = this.iterator(opt); (function next() { iter.next(function(err, key, value) { diff --git a/lib/bcoin/pool.js b/lib/bcoin/pool.js index f8fda718..ddaad66e 100644 --- a/lib/bcoin/pool.js +++ b/lib/bcoin/pool.js @@ -1571,8 +1571,8 @@ Pool.prototype.has = function has(type, hash, force, callback) { if (this.rejects.test(hash, 'hex')) { callback = utils.asyncify(callback); bcoin.debug( - 'Peer sent a known reject: %s (%s).', - hash, peer.hostname); + 'Peer sent a known reject: %s.', + hash); return callback(null, true); } } @@ -2205,8 +2205,6 @@ function BroadcastItem(pool, item, callback) { ? constants.inv.TX : constants.inv.BLOCK; this.msg = item; - this.normalValue = item.renderNormal(); - this.witnessValue = item.render(); // INV does not set the witness // mask (only GETDATA does this). @@ -2297,11 +2295,19 @@ BroadcastItem.prototype.finish = function finish(err) { BroadcastItem.prototype.sendTo = function sendTo(peer, witness) { var self = this; - var value = witness ? this.witnessValue : this.normalValue; - var packetType = this.type === constants.inv.TX ? 'tx' : 'block'; - var i; + var i, data; - peer.write(peer.framer.packet(packetType, value)); + if (this.type === constants.inv.TX) { + data = witness + ? peer.framer.witnessTX(this.msg) + : peer.framer.tx(this.msg); + } else { + data = witness + ? peer.framer.witnessBlock(this.msg) + : peer.framer.block(this.msg); + } + + peer.write(value); setTimeout(function() { self.emit('ack', peer); diff --git a/lib/bcoin/walletdb.js b/lib/bcoin/walletdb.js index 84b47d3d..b71afc08 100644 --- a/lib/bcoin/walletdb.js +++ b/lib/bcoin/walletdb.js @@ -714,16 +714,25 @@ WalletDB.prototype.update = function update(wallet, address) { 'W/' + address.getKeyHash('hex') + '/' + wallet.id, DUMMY); + if (this.tx.filter) + this.tx.filter.add(address.getKeyHash()); + if (address.type === 'multisig') { batch.put( 'W/' + address.getScriptHash('hex') + '/' + wallet.id, DUMMY); + + if (this.tx.filter) + this.tx.filter.add(address.getScriptHash()); } if (address.witness) { batch.put( 'W/' + address.getProgramHash('hex') + '/' + wallet.id, DUMMY); + + if (this.tx.filter) + this.tx.filter.add(address.getProgramHash()); } batch.write(function(err) {