Browse Source

Revert "Add broadcast stats"

This reverts commit 8b096dbeb8.
pool
Sammy Libre 8 years ago
parent
commit
8ea446f333
  1. 22
      go-pool/stratum/handlers.go

22
go-pool/stratum/handlers.go

@ -4,9 +4,7 @@ import ( @@ -4,9 +4,7 @@ import (
"log"
"regexp"
"strings"
"sync"
"sync/atomic"
"time"
"../util"
)
@ -108,34 +106,24 @@ func (s *StratumServer) broadcastNewJobs() { @@ -108,34 +106,24 @@ func (s *StratumServer) broadcastNewJobs() {
defer s.sessionsMu.RUnlock()
count := len(s.sessions)
log.Printf("Broadcasting new jobs to %d miners", count)
start := time.Now()
slots := make(chan bool, 1024*16)
var ok, fails int64
var wg sync.WaitGroup
bcast := make(chan int, 1024*16)
n := 0
for m := range s.sessions {
wg.Add(1)
slots <- true
n++
bcast <- n
go func(cs *Session) {
reply := cs.getJob(t)
err := cs.pushMessage("job", &reply)
<-slots
<-bcast
if err != nil {
log.Printf("Job transmit error to %s: %v", cs.ip, err)
atomic.AddInt64(&fails, 1)
wg.Done()
s.removeSession(cs)
} else {
atomic.AddInt64(&ok, 1)
s.setDeadline(cs.conn)
wg.Done()
}
}(m)
}
wg.Wait()
log.Printf("Done jobs broadcast in %s for %d/%d/%d miners", time.Since(start), count, ok, fails)
}
func (s *StratumServer) refreshBlockTemplate(bcast bool) {

Loading…
Cancel
Save