mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-07-03 03:12:30 +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)
|
templatesLoop(client, miningAddr, newTemplateChan, errChan, templateStopChan)
|
||||||
})
|
})
|
||||||
spawn("solveLoop", func() {
|
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,
|
func solveLoop(newTemplateChan chan *appmessage.GetBlockTemplateResponseMessage, foundBlock chan *externalapi.DomainBlock,
|
||||||
mineWhenNotSynced bool, errChan chan error) {
|
mineWhenNotSynced bool) {
|
||||||
|
|
||||||
var stopOldTemplateSolving chan struct{}
|
var stopOldTemplateSolving chan struct{}
|
||||||
for template := range newTemplateChan {
|
for template := range newTemplateChan {
|
||||||
if stopOldTemplateSolving != nil {
|
|
||||||
close(stopOldTemplateSolving)
|
|
||||||
}
|
|
||||||
if !template.IsSynced && !mineWhenNotSynced {
|
if !template.IsSynced && !mineWhenNotSynced {
|
||||||
log.Warnf("Kaspad is not synced. Skipping current block template")
|
log.Warnf("Kaspad is not synced. Skipping current block template")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if stopOldTemplateSolving != nil {
|
||||||
|
close(stopOldTemplateSolving)
|
||||||
|
}
|
||||||
|
|
||||||
stopOldTemplateSolving = make(chan struct{})
|
stopOldTemplateSolving = make(chan struct{})
|
||||||
block := appmessage.MsgBlockToDomainBlock(template.MsgBlock)
|
block := appmessage.MsgBlockToDomainBlock(template.MsgBlock)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user