From 66730479dee95421a8dea797d776d744b08fb4f6 Mon Sep 17 00:00:00 2001 From: Sammy Libre Date: Wed, 7 Dec 2016 16:49:50 +0500 Subject: [PATCH] Fix difficulty comparison --- go-pool/stratum/miner.go | 10 ++++++---- go-pool/stratum/stratum.go | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/go-pool/stratum/miner.go b/go-pool/stratum/miner.go index 0dcede9..be0efe5 100644 --- a/go-pool/stratum/miner.go +++ b/go-pool/stratum/miner.go @@ -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 { 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 // 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 } diff --git a/go-pool/stratum/stratum.go b/go-pool/stratum/stratum.go index 0715f0e..f91768c 100644 --- a/go-pool/stratum/stratum.go +++ b/go-pool/stratum/stratum.go @@ -48,7 +48,6 @@ type Session struct { enc *json.Encoder ip string endpoint *Endpoint - difficulty int64 validJobs []*Job lastBlockHeight int64 }