mirror of
https://github.com/kvazar-network/keva-stratum.git
synced 2025-01-11 15:48:00 +00:00
Fix difficulty comparison
This commit is contained in:
parent
7c0233fc03
commit
66730479de
@ -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
|
||||
}
|
||||
|
@ -48,7 +48,6 @@ type Session struct {
|
||||
enc *json.Encoder
|
||||
ip string
|
||||
endpoint *Endpoint
|
||||
difficulty int64
|
||||
validJobs []*Job
|
||||
lastBlockHeight int64
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user