From 075e445fef507a667a631317e7016bbab0b839a1 Mon Sep 17 00:00:00 2001 From: Boris Kubiak Date: Tue, 16 Jan 2018 20:35:22 +0100 Subject: [PATCH] Improve performance a little bit --- js/index.js | 8 ++------ js/vanity.js | 10 +++++++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/js/index.js b/js/index.js index a414c96..cf907b8 100644 --- a/js/index.js +++ b/js/index.js @@ -103,9 +103,7 @@ new Vue({ for (let w = this.workers.length; w < this.threads; w++) { try { this.workers[w] = new Worker('js/bundle.js'); - this.workers[w].onmessage = function (event) { - self.parseWorkerMessage(event.data, w); - }; + this.workers[w].onmessage = event => self.parseWorkerMessage(event.data); } catch (err) { this.error = 'local_workers_forbidden'; break; @@ -113,7 +111,7 @@ new Vue({ } }, - parseWorkerMessage: function (wallet, w) { + parseWorkerMessage: function (wallet) { if (wallet.error) { this.stopGen(); this.error = wallet.error; @@ -127,8 +125,6 @@ new Vue({ } this.incrementCounter(wallet.attempts); - - this.workers[w].postMessage(this.input); }, startGen: function () { diff --git a/js/vanity.js b/js/vanity.js index 711143d..6a8e84b 100644 --- a/js/vanity.js +++ b/js/vanity.js @@ -25,10 +25,14 @@ const getRandomWallet = () => { * @returns {boolean} */ const isValidVanityWallet = (wallet, input, isChecksum) => { - if (!isChecksum) { - return wallet.address.substr(2, input.length) === input; + if (input !== wallet.address.substr(2, input.length)) { + return false; } - const address = ethUtils.stripHexPrefix(wallet.address).toLowerCase(); + if (!isChecksum) { + return true; + } + + const address = wallet.address.substr(2); const hash = ethUtils.sha3(address).toString('hex'); for (let i = 0; i < input.length; i++) {