Browse Source

Fix difficulty comparison

pool
Sammy Libre 8 years ago
parent
commit
66730479de
  1. 10
      go-pool/stratum/miner.go
  2. 1
      go-pool/stratum/stratum.go

10
go-pool/stratum/miner.go

@ -20,7 +20,6 @@ type Job struct { @@ -20,7 +20,6 @@ type Job struct {
id string
extraNonce uint32
height int64
difficulty int64
submissions map[string]struct{}
}
@ -63,7 +62,11 @@ func (cs *Session) getJob(t *BlockTemplate) *JobReplyData { @@ -63,7 +62,11 @@ func (cs *Session) getJob(t *BlockTemplate) *JobReplyData {
extraNonce := atomic.AddUint32(&cs.endpoint.extraNonce, 1)
blob := t.nextBlob(extraNonce, cs.endpoint.instanceId)
id := atomic.AddUint64(&cs.endpoint.jobSequence, 1)
job := &Job{id: strconv.FormatUint(id, 10), extraNonce: extraNonce, height: t.height, difficulty: cs.difficulty}
job := &Job{
id: strconv.FormatUint(id, 10),
extraNonce: extraNonce,
height: t.height,
}
job.submissions = make(map[string]struct{})
cs.pushJob(job)
reply := &JobReplyData{JobId: job.id, Blob: blob, Target: cs.endpoint.targetHex}
@ -190,12 +193,11 @@ func (m *Miner) processShare(s *StratumServer, e *Endpoint, job *Job, t *BlockTe @@ -190,12 +193,11 @@ func (m *Miner) processShare(s *StratumServer, e *Endpoint, job *Job, t *BlockTe
// Immediately refresh current BT and send new jobs
s.refreshBlockTemplate(true)
}
} else if hashDiff < job.difficulty {
} else if hashDiff < e.config.Difficulty {
log.Printf("Rejected low difficulty share of %v from %v@%v", hashDiff, m.id, m.ip)
atomic.AddUint64(&m.invalidShares, 1)
return false
}
log.Printf("Valid share at difficulty %v/%v", e.config.Difficulty, hashDiff)
return true
}

1
go-pool/stratum/stratum.go

@ -48,7 +48,6 @@ type Session struct { @@ -48,7 +48,6 @@ type Session struct {
enc *json.Encoder
ip string
endpoint *Endpoint
difficulty int64
validJobs []*Job
lastBlockHeight int64
}

Loading…
Cancel
Save