fix(proxy): stabilise worker snapshots
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
b16ebc1a28
commit
6d6da10885
1 changed files with 14 additions and 1 deletions
|
|
@ -1331,7 +1331,9 @@ func (w *Workers) List() []WorkerRecord {
|
|||
w.mu.RLock()
|
||||
defer w.mu.RUnlock()
|
||||
out := make([]WorkerRecord, len(w.entries))
|
||||
copy(out, w.entries)
|
||||
for i := range w.entries {
|
||||
out[i] = cloneWorkerRecord(w.entries[i])
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
|
|
@ -1384,6 +1386,17 @@ func (r *WorkerRecord) Hashrate(seconds int) float64 {
|
|||
return float64(total) / float64(seconds)
|
||||
}
|
||||
|
||||
func cloneWorkerRecord(record WorkerRecord) WorkerRecord {
|
||||
cloned := record
|
||||
for i := range record.windows {
|
||||
if len(record.windows[i].buckets) == 0 {
|
||||
continue
|
||||
}
|
||||
cloned.windows[i].buckets = append([]uint64(nil), record.windows[i].buckets...)
|
||||
}
|
||||
return cloned
|
||||
}
|
||||
|
||||
// Apply parses login suffixes and applies the configured global difficulty.
|
||||
func (cd *CustomDiff) Apply(miner *Miner) {
|
||||
if cd == nil || miner == nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue