Browse Source

PersonalLuck

master
yuriy0803 3 years ago
parent
commit
a7d5b58e82
  1. 2
      storage/redis.go
  2. 10
      www/app/controllers/account.js
  3. 2
      www/app/templates/account.hbs

2
storage/redis.go

@ -541,6 +541,7 @@ func (r *RedisClient) WriteBlock(login, id string, params []string, diff, roundD
r.writeShare(tx, ms, ts, login, id, diff, window)
tx.HSet(r.formatKey("stats"), "lastBlockFound", strconv.FormatInt(ts, 10))
tx.HDel(r.formatKey("stats"), "roundShares")
tx.HSet(r.formatKey("miners", login), "roundShares", strconv.FormatInt(0, 10))
tx.ZIncrBy(r.formatKey("finders"), 1, login)
tx.HIncrBy(r.formatKey("miners", login), "blocksFound", 1)
tx.HGetAllMap(r.formatKey("shares", "roundCurrent"))
@ -592,6 +593,7 @@ func (r *RedisClient) writeShare(tx *redis.Multi, ms, ts int64, login, id string
tx.LPush(r.formatKey("lastshares"), login)
}
tx.LTrim(r.formatKey("lastshares"), 0, r.pplns)
tx.HIncrBy(r.formatKey("miners", login), "roundShares", diff)
tx.HIncrBy(r.formatKey("shares", "roundCurrent"), login, diff)
tx.ZAdd(r.formatKey("hashrate"), redis.Z{Score: float64(ts), Member: join(diff, login, id, ms)})
tx.ZAdd(r.formatKey("hashrate", login), redis.Z{Score: float64(ts), Member: join(diff, id, ms)})

10
www/app/controllers/account.js

@ -4,6 +4,16 @@ export default Ember.Controller.extend({
applicationController: Ember.inject.controller('application'),
stats: Ember.computed.reads('applicationController.model.stats'),
PersonalLuck: Ember.computed("stats", "model", {
get() {
var percent = this.get("model.stats.roundShares") / this.get("applicationController.difficulty");
if (!percent) {
return 0;
}
return percent;
},
}),
roundPercent: Ember.computed('stats', 'model', {
get() {
var percent = this.get('model.roundShares') / this.get('stats.nShares');

2
www/app/templates/account.hbs

@ -28,6 +28,8 @@
<div style="display: block;"><i class="fa fa-gears"></i> Workers Online: <span>{{format-number model.workersOnline}}</span></div>
<div style="display: block;"><i class="fa fa-tachometer"></i> Hashrate (30m): <span>{{format-hashrate model.currentHashrate}}</span></div>
<div style="display: block;"><i class="fa fa-tachometer"></i> Hashrate (3h): <span>{{format-hashrate model.hashrate}}</span></div>
<div style="display: block;"><i class="fa fa-gears"></i> Personal Luck: <span>{{format-number PersonalLuck style='percent'}}</span></div>
</div>
<div class="col-md-4 stats">
<div style="display: block;"><i class="fa fa-tachometer"></i> Blocks Found: <span>{{format-number model.stats.blocksFound fallback='0'}}</span></div>

Loading…
Cancel
Save