From d5690db2eaffb84da52b6180e1c4998e82145586 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Thu, 9 May 2019 06:24:17 +0700 Subject: [PATCH] Emit found event --- bench/index.js | 15 +++++++++------ src/index.js | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/bench/index.js b/bench/index.js index 87efd33..c0193fc 100644 --- a/bench/index.js +++ b/bench/index.js @@ -14,10 +14,13 @@ vain.on('update', data => { console.log(`Duration: ${duration} | Attempts: ${attempts} | Speed: ${speed}`); }); +vain.on('found', data => { + console.log(); + console.log(`Address: ${data.address}`); + console.log(`WIF: ${data.wif}`); + console.log(); + console.log(`Found in ${prettyMs(data.duration)}`); + console.log(`Speed: ${data.addressesPerSecond} addr/s`); +}); + const result = vain.start(); -console.log(); -console.log(`Address: ${result.address}`); -console.log(`WIF: ${result.wif}`); -console.log(); -console.log(`Found in ${prettyMs(result.duration)}`); -console.log(`Addresses per second: ${result.addressesPerSecond}`); diff --git a/src/index.js b/src/index.js index 879df22..9184957 100644 --- a/src/index.js +++ b/src/index.js @@ -44,12 +44,12 @@ class Vain extends Emitter { const duration = endTime - startTime; const addressesPerSecond = Math.floor(attempts / (duration / ONE_SECOND)); - return { + this.emit('found', { duration, addressesPerSecond, address, wif: keyPair.toWIF() - }; + }); } }