Skip to content

Commit

Permalink
Write Login to redis.
Browse files Browse the repository at this point in the history
  • Loading branch information
Triet committed Aug 22, 2017
1 parent 900efe0 commit 9a97a89
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"threads": 4,
"coin": "eth",
"name": "main",
"name": "ropsten",

"proxy": {
"enabled": true,
Expand All @@ -11,8 +11,8 @@
"behindReverseProxy": false,
"blockRefreshInterval": "120ms",
"stateUpdateInterval": "3s",
"difficulty": 2000000000,
"hashrateExpiration": "3h",
"difficulty": 1000000000,
"hashrateExpiration": "24h",

"healthCheck": true,
"maxFails": 100,
Expand Down Expand Up @@ -62,7 +62,7 @@
"upstreamCheckInterval": "5s",
"upstream": [
{
"name": "main",
"name": "ropsten",
"url": "http://127.0.0.1:8545",
"timeout": "10s"
},
Expand All @@ -81,7 +81,7 @@
},

"unlocker": {
"enabled": false,
"enabled": true,
"poolFee": 1.0,
"poolFeeAddress": "",
"donate": true,
Expand Down
6 changes: 4 additions & 2 deletions storage/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type RedisClient struct {
}

type BlockData struct {
Login string `json:"login"`
Height int64 `json:"height"`
Timestamp int64 `json:"timestamp"`
Difficulty int64 `json:"difficulty"`
Expand Down Expand Up @@ -63,7 +64,7 @@ func (b *BlockData) RoundKey() string {
}

func (b *BlockData) key() string {
return join(b.UncleHeight, b.Orphan, b.Nonce, b.serializeHash(), b.Timestamp, b.Difficulty, b.TotalShares, b.Reward)
return join(b.UncleHeight, b.Orphan, b.Nonce, b.serializeHash(), b.Timestamp, b.Difficulty, b.TotalShares, b.Reward, b.Login)
}

type Miner struct {
Expand Down Expand Up @@ -224,7 +225,7 @@ func (r *RedisClient) WriteBlock(login, id string, params []string, diff, roundD
totalShares += n
}
hashHex := strings.Join(params, ":")
s := join(hashHex, ts, roundDiff, totalShares)
s := join(hashHex, ts, roundDiff, totalShares, login)
cmd := r.client.ZAdd(r.formatKey("blocks", "candidates"), redis.Z{Score: float64(height), Member: s})
return false, cmd.Err()
}
Expand Down Expand Up @@ -832,6 +833,7 @@ func convertCandidateResults(raw *redis.ZSliceCmd) []*BlockData {
block.Timestamp, _ = strconv.ParseInt(fields[3], 10, 64)
block.Difficulty, _ = strconv.ParseInt(fields[4], 10, 64)
block.TotalShares, _ = strconv.ParseInt(fields[5], 10, 64)
block.Login = fields[6]
block.candidateKey = v.Member.(string)
result = append(result, &block)
}
Expand Down

0 comments on commit 9a97a89

Please sign in to comment.