Browse Source

Emit found event

master
Luke Childs 6 years ago
parent
commit
d5690db2ea
  1. 15
      bench/index.js
  2. 4
      src/index.js

15
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}`);

4
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()
};
});
}
}

Loading…
Cancel
Save