Browse Source

Log luck stats for blocks

pool
Sammy Libre 8 years ago
parent
commit
b95f1b8112
  1. 16
      go-pool/stratum/miner.go
  2. 2
      go-pool/stratum/stratum.go

16
go-pool/stratum/miner.go

@ -174,13 +174,19 @@ func (m *Miner) processShare(s *StratumServer, e *Endpoint, job *Job, t *BlockTe
convertedBlob = cnutil.ConvertBlob(shareBuff) convertedBlob = cnutil.ConvertBlob(shareBuff)
} }
blockFastHash := hex.EncodeToString(hashing.FastHash(convertedBlob)) blockFastHash := hex.EncodeToString(hashing.FastHash(convertedBlob))
// Immediately refresh current BT and send new jobs now := util.MakeTimestamp()
s.refreshBlockTemplate(true) roundShares := atomic.SwapInt64(&s.roundShares, 0)
ratio := float64(roundShares) / float64(t.difficulty)
s.blocksMu.Lock()
s.blockStats[now] = ratio
s.blocksMu.Unlock()
atomic.AddUint64(&m.accepts, 1) atomic.AddUint64(&m.accepts, 1)
atomic.AddUint64(&r.Accepts, 1) atomic.AddUint64(&r.Accepts, 1)
atomic.StoreInt64(&s.roundShares, 0) atomic.StoreInt64(&r.LastSubmissionAt, now)
atomic.StoreInt64(&r.LastSubmissionAt, util.MakeTimestamp()) log.Printf("Block %s found at height %d by miner %v@%v with ratio %.4f", blockFastHash[0:6], t.height, m.id, m.ip, ratio)
log.Printf("Block %v found at height %v by miner %v@%v", blockFastHash[0:6], t.height, m.id, m.ip)
// Immediately refresh current BT and send new jobs
s.refreshBlockTemplate(true)
} }
} else if hashDiff < job.difficulty { } else if hashDiff < job.difficulty {
log.Printf("Rejected low difficulty share of %v from %v@%v", hashDiff, m.id, m.ip) log.Printf("Rejected low difficulty share of %v from %v@%v", hashDiff, m.id, m.ip)

2
go-pool/stratum/stratum.go

@ -58,7 +58,7 @@ const (
) )
func NewStratum(cfg *pool.Config) *StratumServer { func NewStratum(cfg *pool.Config) *StratumServer {
stratum := &StratumServer{config: cfg} stratum := &StratumServer{config: cfg, blockStats: make(map[int64]float64)}
stratum.upstreams = make([]*rpc.RPCClient, len(cfg.Upstream)) stratum.upstreams = make([]*rpc.RPCClient, len(cfg.Upstream))
for i, v := range cfg.Upstream { for i, v := range cfg.Upstream {

Loading…
Cancel
Save