walletdb: use set for querying wallets by tx.

This commit is contained in:
Christopher Jeffrey 2017-07-25 11:19:26 -07:00
parent 2d74bda89b
commit d9a726a358
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -1529,7 +1529,7 @@ WalletDB.prototype.resendPending = async function resendPending(wid) {
WalletDB.prototype.getWalletsByTX = async function getWalletsByTX(tx) { WalletDB.prototype.getWalletsByTX = async function getWalletsByTX(tx) {
let hashes = tx.getOutputHashes('hex'); let hashes = tx.getOutputHashes('hex');
let result = []; let result = new Set();
if (!tx.isCoinbase()) { if (!tx.isCoinbase()) {
for (let input of tx.inputs) { for (let input of tx.inputs) {
@ -1545,7 +1545,7 @@ WalletDB.prototype.getWalletsByTX = async function getWalletsByTX(tx) {
continue; continue;
for (let wid of map.wids) for (let wid of map.wids)
util.binaryInsert(result, wid, cmp, true); result.add(wid);
} }
} }
@ -1561,10 +1561,10 @@ WalletDB.prototype.getWalletsByTX = async function getWalletsByTX(tx) {
continue; continue;
for (let wid of map.wids) for (let wid of map.wids)
util.binaryInsert(result, wid, cmp, true); result.add(wid);
} }
if (result.length === 0) if (result.size === 0)
return; return;
return result; return result;