mirror of https://github.com/status-im/op-geth.git
put unlock after lock
This commit is contained in:
parent
618065895b
commit
652eea71fe
|
@ -61,10 +61,10 @@ func (self *CpuAgent) Stop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CpuAgent) Start() {
|
func (self *CpuAgent) Start() {
|
||||||
defer self.mu.Unlock()
|
|
||||||
self.mu.Lock()
|
self.mu.Lock()
|
||||||
|
defer self.mu.Unlock()
|
||||||
|
|
||||||
if atomic.LoadInt32(&self.isMining) == 1 {
|
if !atomic.CompareAndSwapInt32(&self.isMining, 0, 1) {
|
||||||
return // agent already started
|
return // agent already started
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,8 +74,6 @@ func (self *CpuAgent) Start() {
|
||||||
self.workCh = make(chan *Work, 1)
|
self.workCh = make(chan *Work, 1)
|
||||||
|
|
||||||
go self.update()
|
go self.update()
|
||||||
|
|
||||||
atomic.StoreInt32(&self.isMining, 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CpuAgent) update() {
|
func (self *CpuAgent) update() {
|
||||||
|
|
Loading…
Reference in New Issue