Skip to content

Commit

Permalink
Fix: avoid duplicate snapshot update and no newWorkRequest for non miner
Browse files Browse the repository at this point in the history
  • Loading branch information
jennwiederholen committed Jun 21, 2024
1 parent 36e70a7 commit cb4da14
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ func (w *worker) newWorkLoopEx(recommit time.Duration) {

// commitSimple just starts a new commitNewWork
commitSimple := func() {
if atomic.CompareAndSwapInt32(&busyMining, 0, 1) {
if wemixminer.AmPartner() && atomic.CompareAndSwapInt32(&busyMining, 0, 1) {
w.newWorkCh <- &newWorkReq{interrupt: nil, noempty: false, timestamp: time.Now().Unix()}
atomic.StoreInt32(&w.newTxs, 0)
atomic.StoreInt32(&busyMining, 0)
Expand Down Expand Up @@ -599,10 +599,8 @@ func (w *worker) mainLoop() {
// In wemix, costly interrupt / resubmit is disabled
if wemixminer.IsPoW() {
w.commitWork(req.interrupt, req.noempty, req.timestamp)
} else if wemixminer.AmPartner() {
w.commitWork(nil, req.noempty, req.timestamp)
} else {
w.refreshPending(true)
w.commitWork(nil, req.noempty, req.timestamp)
}

case req := <-w.getWorkCh:
Expand Down Expand Up @@ -1773,6 +1771,7 @@ func (w *worker) commitEx(env *environment, interval func(), update bool, start

if update {
w.updateSnapshot(env)
update = false
}
time.Sleep(time.Until(*env.till))

Expand Down

0 comments on commit cb4da14

Please sign in to comment.