fix lowlevelup and walletdb.

This commit is contained in:
Christopher Jeffrey 2016-05-21 22:57:13 -07:00
parent cf041e1fad
commit 5fb8727a80
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
3 changed files with 36 additions and 21 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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) {