Skip to content

Commit

Permalink
[bugFix] revenue
Browse files Browse the repository at this point in the history
  • Loading branch information
Command M committed Sep 21, 2019
1 parent f943c67 commit 6f1f10c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
10 changes: 4 additions & 6 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,16 @@ func (db *database) calcRevenueToday(totalRevenue uint64) {

allMinersRevenueTable := make(map[string]interface{})
for miner, shares := range allMinersSharesTable {
allMinersRevenueTable[miner] = shares / totalShare * totalRevenue
revenue := shares / totalShare * totalRevenue
allMinersRevenueTable[miner] = revenue

payment, _ := db.client.HGet("user:"+miner, "payment").Result()
_, _ = fmt.Fprintf(f, "%s %d %s\n", miner, allMinersSharesTable[miner], payment)
_, _ = fmt.Fprintf(f, "%s %d %s\n", miner, revenue, payment)

date, _ := strconv.ParseFloat(time.Now().Format("20190102"), 10)
z := redis.Z{
Score: date,
Member: strconv.FormatUint(allMinersSharesTable[miner], 10) + ":" + strconv.FormatInt(int64(date), 10),
Member: strconv.FormatUint(revenue, 10) + ":" + strconv.FormatInt(int64(date), 10),
}
_, err := db.client.ZAdd("revenue:"+miner, z).Result()
if err != nil {
Expand Down

0 comments on commit 6f1f10c

Please sign in to comment.