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
|
id string
|
||||||
extraNonce uint32
|
extraNonce uint32
|
||||||
height int64
|
height int64
|
||||||
difficulty int64
|
|
||||||
submissions map[string]struct{}
|
submissions map[string]struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +62,11 @@ func (cs *Session) getJob(t *BlockTemplate) *JobReplyData {
|
|||||||
extraNonce := atomic.AddUint32(&cs.endpoint.extraNonce, 1)
|
extraNonce := atomic.AddUint32(&cs.endpoint.extraNonce, 1)
|
||||||
blob := t.nextBlob(extraNonce, cs.endpoint.instanceId)
|
blob := t.nextBlob(extraNonce, cs.endpoint.instanceId)
|
||||||
id := atomic.AddUint64(&cs.endpoint.jobSequence, 1)
|
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{})
|
job.submissions = make(map[string]struct{})
|
||||||
cs.pushJob(job)
|
cs.pushJob(job)
|
||||||
reply := &JobReplyData{JobId: job.id, Blob: blob, Target: cs.endpoint.targetHex}
|
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
|
// Immediately refresh current BT and send new jobs
|
||||||
s.refreshBlockTemplate(true)
|
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)
|
log.Printf("Rejected low difficulty share of %v from %v@%v", hashDiff, m.id, m.ip)
|
||||||
atomic.AddUint64(&m.invalidShares, 1)
|
atomic.AddUint64(&m.invalidShares, 1)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Valid share at difficulty %v/%v", e.config.Difficulty, hashDiff)
|
log.Printf("Valid share at difficulty %v/%v", e.config.Difficulty, hashDiff)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,6 @@ type Session struct {
|
|||||||
enc *json.Encoder
|
enc *json.Encoder
|
||||||
ip string
|
ip string
|
||||||
endpoint *Endpoint
|
endpoint *Endpoint
|
||||||
difficulty int64
|
|
||||||
validJobs []*Job
|
validJobs []*Job
|
||||||
lastBlockHeight int64
|
lastBlockHeight int64
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user