open-ethereum-pool
open-ethereum-pool copied to clipboard
Find out the meaning of the code
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
Line by line
- Increment share counter for current round (1 round is 1 block)
- Add share entry for global pool stat.
- Add share entry for specific miner
- Add share entry expiration time
- Put timestamp of last valid share to miner.