From e3952b243b1f65bccd591dfe34cf1267ccaf74cd Mon Sep 17 00:00:00 2001 From: frankcrypto Date: Tue, 26 Sep 2023 17:18:05 +0800 Subject: [PATCH] fix cpu miner deadlock --- cmd/miner/symbols/lib/robot.go | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/cmd/miner/symbols/lib/robot.go b/cmd/miner/symbols/lib/robot.go index b81729bf..4eaed991 100644 --- a/cmd/miner/symbols/lib/robot.go +++ b/cmd/miner/symbols/lib/robot.go @@ -9,18 +9,19 @@ import ( "encoding/hex" "errors" "fmt" - "github.com/Qitmeer/qng/cmd/miner/common" - "github.com/Qitmeer/qng/cmd/miner/core" - "github.com/Qitmeer/qng/common/hash" - "github.com/Qitmeer/qng/core/types" - "github.com/Qitmeer/qng/rpc/client" - "github.com/Qitmeer/qng/rpc/client/cmds" "io/ioutil" "log" "strconv" "strings" "sync" "time" + + "github.com/Qitmeer/qng/cmd/miner/common" + "github.com/Qitmeer/qng/cmd/miner/core" + "github.com/Qitmeer/qng/common/hash" + "github.com/Qitmeer/qng/core/types" + "github.com/Qitmeer/qng/rpc/client" + "github.com/Qitmeer/qng/rpc/client/cmds" ) const ( @@ -257,18 +258,15 @@ func (this *QitmeerRobot) SubmitWork() { this.InvalidShares++ } } - this.SubmitLock.Unlock() - if err != ErrLimitWork { // limit wait block connect - time.AfterFunc(1*time.Second, func() { - this.SubmitLock.Lock() - r := this.Work.Get() - this.SubmitLock.Unlock() - if this.Work.Block != nil { - common.MinerLoger.Info("Change Task", "height", this.Work.Block.Height) - } - this.NotifyWork(r) - }) - } + time.AfterFunc(1*time.Second, func() { + //this.SubmitLock.Lock() + r := this.Work.Get() + this.SubmitLock.Unlock() + if this.Work.Block != nil { + common.MinerLoger.Info("Change Task", "height", this.Work.Block.Height) + } + this.NotifyWork(r) + }) } else { if !this.Pool { // solo this.PendingLock.Lock()