open-ethereum-pool icon indicating copy to clipboard operation
open-ethereum-pool copied to clipboard

Find out the meaning of the code

Open Jerry170617 opened this issue 6 years ago • 1 comments

redis.go

func (r *RedisClient) writeShare(tx *redis.Multi, ms, ts int64, login, id string, diff int64, expire time.Duration) { 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)}) tx.Expire(r.formatKey("hashrate", login), expire) // Will delete hashrates for miners that gone tx.HSet(r.formatKey("miners", login), "lastShare", strconv.FormatInt(ts, 10)) } Find out the meaning of the code

Jerry170617 avatar Mar 23 '18 06:03 Jerry170617

Line by line

  1. Increment share counter for current round (1 round is 1 block)
  2. Add share entry for global pool stat.
  3. Add share entry for specific miner
  4. Add share entry expiration time
  5. Put timestamp of last valid share to miner.

aemet93 avatar Jan 22 '20 11:01 aemet93