fix lowlevelup and walletdb.
This commit is contained in:
parent
cf041e1fad
commit
5fb8727a80
@ -237,9 +237,9 @@ LowlevelUp.prototype.fetch = function fetch(key, parse, callback) {
|
|||||||
|
|
||||||
LowlevelUp.prototype.iterate = function iterate(options, callback) {
|
LowlevelUp.prototype.iterate = function iterate(options, callback) {
|
||||||
var items = [];
|
var items = [];
|
||||||
var iter;
|
var iter, opt;
|
||||||
|
|
||||||
options = {
|
opt = {
|
||||||
gte: options.gte,
|
gte: options.gte,
|
||||||
lte: options.lte,
|
lte: options.lte,
|
||||||
keys: true,
|
keys: true,
|
||||||
@ -250,22 +250,22 @@ LowlevelUp.prototype.iterate = function iterate(options, callback) {
|
|||||||
reverse: options.reverse
|
reverse: options.reverse
|
||||||
};
|
};
|
||||||
|
|
||||||
if (options.gte == null)
|
if (opt.gte == null)
|
||||||
delete options.gte;
|
delete opt.gte;
|
||||||
|
|
||||||
if (options.lte == null)
|
if (opt.lte == null)
|
||||||
delete options.lte;
|
delete opt.lte;
|
||||||
|
|
||||||
if (options.values == null)
|
if (opt.values == null)
|
||||||
delete options.values;
|
delete opt.values;
|
||||||
|
|
||||||
if (options.limit == null)
|
if (opt.limit == null)
|
||||||
delete options.limit;
|
delete opt.limit;
|
||||||
|
|
||||||
if (options.reverse == null)
|
if (opt.reverse == null)
|
||||||
delete options.reverse;
|
delete opt.reverse;
|
||||||
|
|
||||||
iter = this.iterator(options);
|
iter = this.iterator(opt);
|
||||||
|
|
||||||
(function next() {
|
(function next() {
|
||||||
iter.next(function(err, key, value) {
|
iter.next(function(err, key, value) {
|
||||||
|
|||||||
@ -1571,8 +1571,8 @@ Pool.prototype.has = function has(type, hash, force, callback) {
|
|||||||
if (this.rejects.test(hash, 'hex')) {
|
if (this.rejects.test(hash, 'hex')) {
|
||||||
callback = utils.asyncify(callback);
|
callback = utils.asyncify(callback);
|
||||||
bcoin.debug(
|
bcoin.debug(
|
||||||
'Peer sent a known reject: %s (%s).',
|
'Peer sent a known reject: %s.',
|
||||||
hash, peer.hostname);
|
hash);
|
||||||
return callback(null, true);
|
return callback(null, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2205,8 +2205,6 @@ function BroadcastItem(pool, item, callback) {
|
|||||||
? constants.inv.TX
|
? constants.inv.TX
|
||||||
: constants.inv.BLOCK;
|
: constants.inv.BLOCK;
|
||||||
this.msg = item;
|
this.msg = item;
|
||||||
this.normalValue = item.renderNormal();
|
|
||||||
this.witnessValue = item.render();
|
|
||||||
|
|
||||||
// INV does not set the witness
|
// INV does not set the witness
|
||||||
// mask (only GETDATA does this).
|
// mask (only GETDATA does this).
|
||||||
@ -2297,11 +2295,19 @@ BroadcastItem.prototype.finish = function finish(err) {
|
|||||||
|
|
||||||
BroadcastItem.prototype.sendTo = function sendTo(peer, witness) {
|
BroadcastItem.prototype.sendTo = function sendTo(peer, witness) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var value = witness ? this.witnessValue : this.normalValue;
|
var i, data;
|
||||||
var packetType = this.type === constants.inv.TX ? 'tx' : 'block';
|
|
||||||
var i;
|
|
||||||
|
|
||||||
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() {
|
setTimeout(function() {
|
||||||
self.emit('ack', peer);
|
self.emit('ack', peer);
|
||||||
|
|||||||
@ -714,16 +714,25 @@ WalletDB.prototype.update = function update(wallet, address) {
|
|||||||
'W/' + address.getKeyHash('hex') + '/' + wallet.id,
|
'W/' + address.getKeyHash('hex') + '/' + wallet.id,
|
||||||
DUMMY);
|
DUMMY);
|
||||||
|
|
||||||
|
if (this.tx.filter)
|
||||||
|
this.tx.filter.add(address.getKeyHash());
|
||||||
|
|
||||||
if (address.type === 'multisig') {
|
if (address.type === 'multisig') {
|
||||||
batch.put(
|
batch.put(
|
||||||
'W/' + address.getScriptHash('hex') + '/' + wallet.id,
|
'W/' + address.getScriptHash('hex') + '/' + wallet.id,
|
||||||
DUMMY);
|
DUMMY);
|
||||||
|
|
||||||
|
if (this.tx.filter)
|
||||||
|
this.tx.filter.add(address.getScriptHash());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (address.witness) {
|
if (address.witness) {
|
||||||
batch.put(
|
batch.put(
|
||||||
'W/' + address.getProgramHash('hex') + '/' + wallet.id,
|
'W/' + address.getProgramHash('hex') + '/' + wallet.id,
|
||||||
DUMMY);
|
DUMMY);
|
||||||
|
|
||||||
|
if (this.tx.filter)
|
||||||
|
this.tx.filter.add(address.getProgramHash());
|
||||||
}
|
}
|
||||||
|
|
||||||
batch.write(function(err) {
|
batch.write(function(err) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user