walletdb: refactor.
This commit is contained in:
parent
4e4b87b18e
commit
ecd18b9613
@ -1424,6 +1424,38 @@ WalletDB.prototype.resend = co(function* resend() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert all wallet ids for an input
|
||||||
|
* (special behavior for SPV).
|
||||||
|
* @private
|
||||||
|
* @param {Input} input
|
||||||
|
* @param {WalletID[]} result
|
||||||
|
* @returns {Promise}
|
||||||
|
*/
|
||||||
|
|
||||||
|
WalletDB.prototype.testInput = co(function* testInput(input, result) {
|
||||||
|
var i, hash, map;
|
||||||
|
|
||||||
|
if (!this.options.resolution)
|
||||||
|
return;
|
||||||
|
|
||||||
|
hash = input.getHash('hex');
|
||||||
|
|
||||||
|
if (!hash)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!this.testFilter(hash))
|
||||||
|
return;
|
||||||
|
|
||||||
|
map = yield this.getPathMap(hash);
|
||||||
|
|
||||||
|
if (!map)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < map.wids.length; i++)
|
||||||
|
utils.binaryInsert(result, map.wids[i], cmp, true);
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all wallet ids by output addresses and outpoints.
|
* Get all wallet ids by output addresses and outpoints.
|
||||||
* @param {Hash[]} hashes
|
* @param {Hash[]} hashes
|
||||||
@ -1441,32 +1473,16 @@ WalletDB.prototype.getWalletsByTX = co(function* getWalletsByTX(tx) {
|
|||||||
prevout = input.prevout;
|
prevout = input.prevout;
|
||||||
|
|
||||||
if (!this.testFilter(prevout.toRaw())) {
|
if (!this.testFilter(prevout.toRaw())) {
|
||||||
// Special behavior for SPV.
|
yield this.testInput(input, result);
|
||||||
if (this.options.resolution) {
|
|
||||||
hash = input.getHash('hex');
|
|
||||||
|
|
||||||
if (!hash)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!this.testFilter(hash))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
map = yield this.getPathMap(hash);
|
|
||||||
|
|
||||||
if (!map)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for (j = 0; j < map.wids.length; j++)
|
|
||||||
utils.binaryInsert(result, map.wids[j], cmp, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
map = yield this.getOutpointMap(prevout.hash, prevout.index);
|
map = yield this.getOutpointMap(prevout.hash, prevout.index);
|
||||||
|
|
||||||
if (!map)
|
if (!map) {
|
||||||
|
yield this.testInput(input, result);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (j = 0; j < map.wids.length; j++)
|
for (j = 0; j < map.wids.length; j++)
|
||||||
utils.binaryInsert(result, map.wids[j], cmp, true);
|
utils.binaryInsert(result, map.wids[j], cmp, true);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user