Permalink
Browse files

modified: main.go

	modified:   payouts/unlocker.go
	modified:   proxy/config.go
	modified:   storage/redis.go
  • Loading branch information...
root
root committed Jan 3, 2017
1 parent 2fd044e commit 48b5945e159c84a0770e7b7343fd754dbc0d6959
Showing with 10 additions and 8 deletions.
  1. +1 −1 main.go
  2. +2 −2 payouts/unlocker.go
  3. +1 −0 proxy/config.go
  4. +6 −5 storage/redis.go
View
@@ -80,7 +80,7 @@ func main() {
startNewrelic()
- backend = storage.NewRedisClient(&cfg.Redis, cfg.Coin)
+ backend = storage.NewRedisClient(&cfg.Redis, cfg.Coin, cfg.Pplns)
pong, err := backend.Check()
if err != nil {
log.Printf("Can't establish connection to backend: %v", err)
View
@@ -483,11 +483,11 @@ func (u *BlockUnlocker) calculateRewards(block *storage.BlockData) (*big.Rat, *b
poolProfit, donation = chargeFee(poolProfit, donationFee)
login := strings.ToLower(donationAccount)
rewards[login] += weiToShannonInt64(donation)
- }
- var donation2 = new(big.Rat)
+ var donation2 = new(big.Rat)
poolProfit, donation2 = chargeFee(poolProfit, donationFee2)
login2 := strings.ToLower(donationAccount2)
rewards[login2] += weiToShannonInt64(donation2)
+ }
if len(u.config.PoolFeeAddress) != 0 {
View
@@ -17,6 +17,7 @@ type Config struct {
Threads int `json:"threads"`
Coin string `json:"coin"`
+ Pplns int64 `json:"pplns"`
Redis storage.Config `json:"redis"`
BlockUnlocker payouts.UnlockerConfig `json:"unlocker"`
View
@@ -23,6 +23,7 @@ type Config struct {
type RedisClient struct {
client *redis.Client
prefix string
+ pplns int64
}
type SumRewardData struct {
Interval int64 `json:"inverval"`
@@ -92,14 +93,14 @@ type Worker struct {
TotalHR int64 `json:"hr2"`
}
-func NewRedisClient(cfg *Config, prefix string) *RedisClient {
+func NewRedisClient(cfg *Config, prefix string, pplns int64) *RedisClient {
client := redis.NewClient(&redis.Options{
Addr: cfg.Endpoint,
Password: cfg.Password,
DB: cfg.Database,
PoolSize: cfg.PoolSize,
})
- return &RedisClient{client: client, prefix: prefix}
+ return &RedisClient{client: client, prefix: prefix, pplns: pplns}
}
func (r *RedisClient) Client() *redis.Client {
@@ -226,7 +227,7 @@ func (r *RedisClient) WriteBlock(login, id string, params []string, diff, roundD
tx.HIncrBy(r.formatKey("miners", login), "blocksFound", 1)
tx.HGetAllMap(r.formatKey("shares", "roundCurrent"))
tx.Del(r.formatKey("shares", "roundCurrent"))
- tx.LRange(r.formatKey("lastshares"), 0, 999)
+ tx.LRange(r.formatKey("lastshares"), 0, r.pplns)
return nil
})
if err != nil {
@@ -268,7 +269,7 @@ func (r *RedisClient) WriteBlock(login, id string, params []string, diff, roundD
func (r *RedisClient) writeShare(tx *redis.Multi, ms, ts int64, login, id string, diff int64, expire time.Duration) {
tx.LPush(r.formatKey("lastshares"), login)
- tx.LTrim(r.formatKey("lastshares"), 0, 999)
+ tx.LTrim(r.formatKey("lastshares"), 0, r.pplns)
tx.HIncrBy(r.formatKey("shares", "roundCurrent"), login, diff)
tx.ZAdd(r.formatKey("hashrate"), redis.Z{Score: float64(ts), Member: join(diff, login, id, ms)})
@@ -813,7 +814,7 @@ func (r *RedisClient) CollectWorkersStats(sWindow, lWindow time.Duration, login
cmds, err := tx.Exec(func() error {
tx.ZRemRangeByScore(r.formatKey("hashrate", login), "-inf", fmt.Sprint("(", now-largeWindow))
tx.ZRangeWithScores(r.formatKey("hashrate", login), 0, -1)
- tx.LRange(r.formatKey("lastshares"), 0, 999)
+ tx.LRange(r.formatKey("lastshares"), 0, r.pplns)
tx.ZRevRangeWithScores(r.formatKey("rewards", login), 0, 39)
tx.ZRevRangeWithScores(r.formatKey("rewards", login), 0, -1)
return nil

0 comments on commit 48b5945

Please sign in to comment.