Fix webui

This commit is contained in:
Jerome Petazzoni
2015-06-08 08:40:13 -07:00
parent 5198933089
commit a6acbce1e7
2 changed files with 5 additions and 21 deletions

View File

@@ -43,7 +43,7 @@ function refresh () {
// Compute instantaneous speed
var s1 = series[i];
var s2 = series[i+1];
var speed = (s2.coins-s1.coins)/(s2.now-s1.now);
var speed = (s2.hashes-s1.hashes)/(s2.now-s1.now);
points.push({ x: s2.now, y: speed });
}
if (graph == null) {

View File

@@ -6,29 +6,13 @@ app.get('/', function (req, res) {
});
app.get('/json', function (req, res) {
redis.lrange('timing', 0, -1, function (err, timing) {
redis.hlen('wallet', function (err, coins) {
timing.reverse();
var speed10 = '?';
var speed100 = '?';
var speed1000 = '?';
if (timing.length >= 10) {
speed10 = 10 / (timing[0]-timing[9]);
}
if (timing.length >= 100) {
speed100 = 100 / (timing[0]-timing[99]);
}
if (timing.length >= 1000) {
speed1000 = 1000 / (timing[0]-timing[999]);
}
redis.hlen('wallet', function (err, coins) {
redis.get('hashes', function (err, hashes) {
var now = Date.now() / 1000;
res.json( {
speed10: speed10,
speed100: speed100,
speed1000: speed1000,
coins: coins,
now: now,
ago: now - timing[0]
hashes: hashes,
now: now
});
});
});