Closed pyskell closed 6 years ago
ETC explorer already has hashrate function, routes/stats.js
named getHashrate()
.
else if (req.body.action=="hashrate")
getHashrate(res);
currently, getHashrate()
has some bug.
/**
Calc difficulty, hashrate from recent blocks in DB
**/
var getHashrate = function(res) {
var hashFind = BlockStat.find({}, "difficulty blockTime")
.lean(true).limit(64).sort('-number');
// highest difficulty / avg blocktime
hashFind.exec(function (err, docs) {
var x = docs.reduce( function(hashR, doc) {
return { "blockTime": hashR.blockTime + doc.blockTime,
"difficulty": Math.max(hashR.difficulty, doc.difficulty) }
}, {"blockTime": 0, "difficulty": 0});
var hashrate = x.difficulty / (1000*x.blockTime / docs.length); // wrong line
res.write(JSON.stringify({"hashrate": hashrate, "difficulty": x.difficulty}));
res.end();
});
}
hashrate
in H/s
is
var hashrate = x.difficulty / (x.blockTime / docs.length); // fixed line
PR #91 is a try to using it.
@pyskell Yup. I use systemctl restart-on=failure option in order to solve the problem "temporary" 😄
There is no parameter blockTime, so it returns empty array. Last fix should have it working now with out crashing and pulling data into the front end,
/fiat
query emit Error: socket hang up
sometimes and cause app.js
crashing.
[1] Error: socket hang up
[1] at createHangUpError (_http_client.js:254:15)
[1] at Socket.socketOnEnd (_http_client.js:346:23)
[1] at emitNone (events.js:91:20)
[1] at Socket.emit (events.js:185:7)
[1] at endReadableNT (_stream_readable.js:974:12)
[1] at _combinedTickCallback (internal/process/next_tick.js:80:11)
[1] at process._tickCallback (internal/process/next_tick.js:104:9)
Fixed. Thanks everyone!
There is no parameter blockTime, so it returns empty array.
and now, Block.blockTime
column is not used at all.
Fixed. Thanks everyone!
so. Who got the bounty ? who is bakon?
Yup, bakon is ethernodeio.
Just FYI proposals are locked-in/signed up for so people avoid duplicating work/competing on changes.
But I also will have more proposals soon 🙂
I'll look into your Block.blockTime
comment.
This is a two-part issue:
grabber.js
calculate and store the data in MongoDB whenever it retrieves new blocks. But implementation details are up to you.Part of an Ecosystem Proposal