mirror of
https://github.com/cryptonote-social/csminer.git
synced 2024-10-26 05:57:11 +03:00
stats improvements n sync improvements
This commit is contained in:
parent
64e33fbf4e
commit
7a8f9ab5d0
@ -126,6 +126,7 @@ func PoolLogin(args *PoolLoginArgs) *PoolLoginResponse {
|
||||
loggedIn = true
|
||||
plArgs = args
|
||||
r.Code = 1
|
||||
go stats.RefreshPoolStats(plArgs.Username)
|
||||
return r
|
||||
}
|
||||
|
||||
@ -189,9 +190,13 @@ func awaitLogin() <-chan *client.MultiClientJob {
|
||||
for {
|
||||
configMutex.Lock()
|
||||
li := loggedIn
|
||||
var uname string
|
||||
if plArgs != nil {
|
||||
uname = plArgs.Username
|
||||
}
|
||||
configMutex.Unlock()
|
||||
if li {
|
||||
crylog.Info("Logged in!")
|
||||
crylog.Info("Logged in:", uname)
|
||||
return cl.StartDispatching()
|
||||
}
|
||||
time.Sleep(time.Second)
|
||||
@ -249,6 +254,8 @@ func MiningLoop(jobChan <-chan *client.MultiClientJob) {
|
||||
if job == nil {
|
||||
crylog.Warn("stratum client died")
|
||||
jobChan = reconnectClient()
|
||||
atomic.StoreUint32(&stopper, 1)
|
||||
wg.Wait()
|
||||
stats.ResetRecent()
|
||||
continue
|
||||
}
|
||||
@ -286,12 +293,31 @@ func MiningLoop(jobChan <-chan *client.MultiClientJob) {
|
||||
func printStats(isMining bool) {
|
||||
s := stats.GetSnapshot(isMining)
|
||||
crylog.Info("=====================================")
|
||||
crylog.Info("Shares [accepted:rejected]:", s.SharesAccepted, ":", s.SharesRejected)
|
||||
crylog.Info("Hashes [client:pool]:", s.ClientSideHashes, ":", s.PoolSideHashes)
|
||||
//crylog.Info("Shares [accepted:rejected]:", s.SharesAccepted, ":", s.SharesRejected)
|
||||
//crylog.Info("Hashes [client:pool]:", s.ClientSideHashes, ":", s.PoolSideHashes)
|
||||
if s.RecentHashrate > 0.0 {
|
||||
crylog.Info("Hashes/sec [inception:recent]:",
|
||||
strconv.FormatFloat(s.Hashrate, 'f', 2, 64), ":",
|
||||
strconv.FormatFloat(s.RecentHashrate, 'f', 2, 64))
|
||||
crylog.Info("Hashrate:", strconv.FormatFloat(s.RecentHashrate, 'f', 2, 64))
|
||||
//strconv.FormatFloat(s.Hashrate, 'f', 2, 64), ":",
|
||||
}
|
||||
configMutex.Lock()
|
||||
uname := plArgs.Username
|
||||
configMutex.Unlock()
|
||||
if s.PoolUsername != "" && uname == s.PoolUsername {
|
||||
crylog.Info("== Pool stats last updated", s.SecondsOld, "seconds ago:")
|
||||
crylog.Info("User :", s.PoolUsername)
|
||||
crylog.Info("Lifetime hashes :", s.LifetimeHashes)
|
||||
crylog.Info("Paid :", strconv.FormatFloat(s.Paid, 'f', 12, 64), "$XMR")
|
||||
if s.Owed > 0.0 {
|
||||
crylog.Info("Owed :", strconv.FormatFloat(s.Owed, 'f', 12, 64), "$XMR")
|
||||
}
|
||||
crylog.Info("Accumulated :", strconv.FormatFloat(s.Accumulated, 'f', 12, 64), "$XMR")
|
||||
crylog.Info("Time to next reward:", s.TimeToReward)
|
||||
if len(s.TimeToReward) > 0 {
|
||||
|
||||
}
|
||||
}
|
||||
if uname != s.PoolUsername || s.SecondsOld > 120 {
|
||||
stats.RefreshPoolStats(uname)
|
||||
}
|
||||
crylog.Info("=====================================")
|
||||
}
|
||||
@ -315,7 +341,7 @@ func goMine(wg *sync.WaitGroup, stopper *uint32, job client.MultiClientJob, thre
|
||||
break
|
||||
}
|
||||
stats.TallyHashes(res)
|
||||
crylog.Info("Share found by thread", thread, "w/ target:", blockchain.HashDifficulty(hash))
|
||||
crylog.Info("Share found by thread:", thread, "Target:", blockchain.HashDifficulty(hash))
|
||||
fnonce := hex.EncodeToString(nonce)
|
||||
// If the client is alive, submit the share in a separate thread so we can resume hashing
|
||||
// immediately, otherwise wait until it's alive.
|
||||
|
@ -1,6 +1,8 @@
|
||||
package stats
|
||||
|
||||
import (
|
||||
//"github.com/cryptonote-social/csminer/crylog"
|
||||
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
@ -23,7 +25,7 @@ var (
|
||||
clientSideHashes, recentHashes int64
|
||||
|
||||
// pool stats
|
||||
lastPoolUserQuery string
|
||||
lastPoolUsername string
|
||||
lastPoolUpdateTime time.Time
|
||||
ppropProgress float64
|
||||
hashrate1, hashrate24 int64
|
||||
@ -77,6 +79,13 @@ type Snapshot struct {
|
||||
SharesAccepted, SharesRejected int64
|
||||
ClientSideHashes, PoolSideHashes int64
|
||||
Hashrate, RecentHashrate float64
|
||||
|
||||
// Pool stats
|
||||
PoolUsername string
|
||||
LifetimeHashes int64
|
||||
Paid, Owed, Accumulated float64
|
||||
TimeToReward string
|
||||
SecondsOld int // how many seconds out of date the pool stats are
|
||||
}
|
||||
|
||||
func GetSnapshot(isMining bool) *Snapshot {
|
||||
@ -103,6 +112,16 @@ func GetSnapshot(isMining bool) *Snapshot {
|
||||
r.Hashrate = float64(clientSideHashes) / elapsedOverall
|
||||
r.RecentHashrate = float64(recentHashes) / elapsedRecent
|
||||
}
|
||||
|
||||
if lastPoolUsername != "" {
|
||||
r.PoolUsername = lastPoolUsername
|
||||
r.LifetimeHashes = lifetimeHashes
|
||||
r.Paid = paid
|
||||
r.Owed = owed
|
||||
r.Accumulated = accumulated
|
||||
r.TimeToReward = timeToReward
|
||||
}
|
||||
r.SecondsOld = int(time.Now().Sub(lastPoolUpdateTime).Seconds())
|
||||
return r
|
||||
}
|
||||
|
||||
@ -192,14 +211,17 @@ func RefreshPoolStats(username string) error {
|
||||
}
|
||||
|
||||
mutex.Lock()
|
||||
lastPoolUserQuery = username
|
||||
lastPoolUsername = username
|
||||
lastPoolUpdateTime = time.Now()
|
||||
ppropProgress = s.CycleProgress / (1.0 + ps.Margin)
|
||||
hashrate1 = s.Hashrate1
|
||||
hashrate24 = s.Hashrate24
|
||||
lifetimeHashes = s.LifetimeHashes
|
||||
paid = s.AmountPaid
|
||||
owed = s.AmountOwed
|
||||
if ps.NextBlockReward > 0.0 && s.CycleProgress > 0.0 {
|
||||
progress := s.CycleProgress / (1.0 + ps.Margin)
|
||||
accumulated = ps.NextBlockReward * progress
|
||||
}
|
||||
timeToReward = ttreward
|
||||
mutex.Unlock()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user