mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
Fix the stopOldTemplateSolving channel in the miner getting closed twice (#1286)
* Fix the stopOldTemplateSolving channel in the miner getting closed twice. * Remove a unused variable.
This commit is contained in:
parent
830ddf4735
commit
0dea766373
@ -89,7 +89,7 @@ func mineNextBlock(client *minerClient, miningAddr util.Address, foundBlock chan
|
||||
templatesLoop(client, miningAddr, newTemplateChan, errChan, templateStopChan)
|
||||
})
|
||||
spawn("solveLoop", func() {
|
||||
solveLoop(newTemplateChan, foundBlock, mineWhenNotSynced, errChan)
|
||||
solveLoop(newTemplateChan, foundBlock, mineWhenNotSynced)
|
||||
})
|
||||
}
|
||||
|
||||
@ -151,18 +151,19 @@ func templatesLoop(client *minerClient, miningAddr util.Address,
|
||||
}
|
||||
|
||||
func solveLoop(newTemplateChan chan *appmessage.GetBlockTemplateResponseMessage, foundBlock chan *externalapi.DomainBlock,
|
||||
mineWhenNotSynced bool, errChan chan error) {
|
||||
mineWhenNotSynced bool) {
|
||||
|
||||
var stopOldTemplateSolving chan struct{}
|
||||
for template := range newTemplateChan {
|
||||
if stopOldTemplateSolving != nil {
|
||||
close(stopOldTemplateSolving)
|
||||
}
|
||||
if !template.IsSynced && !mineWhenNotSynced {
|
||||
log.Warnf("Kaspad is not synced. Skipping current block template")
|
||||
continue
|
||||
}
|
||||
|
||||
if stopOldTemplateSolving != nil {
|
||||
close(stopOldTemplateSolving)
|
||||
}
|
||||
|
||||
stopOldTemplateSolving = make(chan struct{})
|
||||
block := appmessage.MsgBlockToDomainBlock(template.MsgBlock)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user