kaspad/cmd/kaspaminer/templatemanager/templatemanager.go
Ori Newman ee8fa32ff8
Refactor miner and mine when waiting for block to validate (#1481)
* Refactor miner and mine when waiting for block to validate

* Fix -n to work after the refactor.
Change foundBlockChan capacity.
Use lock instead of atomic in the template manager.

* Fix self assignment

* Fix lock

* Fix Dockerfile

* Add comment
2021-02-03 11:53:55 +02:00

24 lines
510 B
Go

package templatemanager
import (
"github.com/kaspanet/kaspad/app/appmessage"
"sync"
)
var currentTemplate *appmessage.GetBlockTemplateResponseMessage
var lock = &sync.Mutex{}
// Get returns the template to work on
func Get() *appmessage.GetBlockTemplateResponseMessage {
lock.Lock()
defer lock.Unlock()
return currentTemplate
}
// Set sets the current template to work on
func Set(template *appmessage.GetBlockTemplateResponseMessage) {
lock.Lock()
defer lock.Unlock()
currentTemplate = template
}