From d9a726a358e36ca41bbe9543d6a4ef309c4e756a Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 25 Jul 2017 11:19:26 -0700 Subject: [PATCH] walletdb: use set for querying wallets by tx. --- lib/wallet/walletdb.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/wallet/walletdb.js b/lib/wallet/walletdb.js index 7e637625..6a122fd0 100644 --- a/lib/wallet/walletdb.js +++ b/lib/wallet/walletdb.js @@ -1529,7 +1529,7 @@ WalletDB.prototype.resendPending = async function resendPending(wid) { WalletDB.prototype.getWalletsByTX = async function getWalletsByTX(tx) { let hashes = tx.getOutputHashes('hex'); - let result = []; + let result = new Set(); if (!tx.isCoinbase()) { for (let input of tx.inputs) { @@ -1545,7 +1545,7 @@ WalletDB.prototype.getWalletsByTX = async function getWalletsByTX(tx) { continue; 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; 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 result;