miner: status event.

This commit is contained in:
Christopher Jeffrey 2016-01-04 05:07:53 -08:00
parent 61da977a3f
commit eef4103296

View File

@ -119,7 +119,7 @@ exports.miner = function miner(options, callback) {
function iter(block) {
timeout = setTimeout(function() {
var hash, begin, hps;
var hash, begin, rate;
begin = utils.now();
@ -133,7 +133,7 @@ exports.miner = function miner(options, callback) {
block.nonce++;
}
hps = (0xffffffff / (utils.now() - begin)) * 2;
rate = (0xffffffff / (utils.now() - begin)) * 2;
block.nonce = 0;
block.extraNonce.iaddn(1);
@ -144,10 +144,10 @@ exports.miner = function miner(options, callback) {
updateMerkle(block);
e.emit('status', {
block: nextBlock,
extraNonce: block.extraNonce,
hps: hps,
target: block.bits
block: block,
target: utils.fromCompact(block.bits),
hashes: block.extraNonce.mul(0xffffffff),
hashrate: rate
});
return iter(block);
@ -203,7 +203,7 @@ module.exports = function mine(pool, options) {
miner.on('status', function(stat) {
if (options.log)
console.log('Hashes per second: %s', stat.hps);
console.log('Hashes per second: %s', stat.hashrate);
});
miner.start();