mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-06 14:16:43 +00:00
Increase the sleep time in kaspaminer when the node is not synced (#1544)
Co-authored-by: stasatdaglabs <39559713+stasatdaglabs@users.noreply.github.com>
This commit is contained in:
parent
5fa06fe7d7
commit
8fbea5d239
@ -2,13 +2,14 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
nativeerrors "errors"
|
nativeerrors "errors"
|
||||||
"github.com/kaspanet/kaspad/cmd/kaspaminer/templatemanager"
|
|
||||||
"github.com/kaspanet/kaspad/domain/consensus/model/pow"
|
|
||||||
"github.com/kaspanet/kaspad/util/difficulty"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/kaspanet/kaspad/cmd/kaspaminer/templatemanager"
|
||||||
|
"github.com/kaspanet/kaspad/domain/consensus/model/pow"
|
||||||
|
"github.com/kaspanet/kaspad/util/difficulty"
|
||||||
|
|
||||||
"github.com/kaspanet/kaspad/domain/consensus/utils/consensushashing"
|
"github.com/kaspanet/kaspad/domain/consensus/utils/consensushashing"
|
||||||
|
|
||||||
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
||||||
@ -155,9 +156,13 @@ func mineNextBlock(mineWhenNotSynced bool) *externalapi.DomainBlock {
|
|||||||
|
|
||||||
func getBlockForMining(mineWhenNotSynced bool) *externalapi.DomainBlock {
|
func getBlockForMining(mineWhenNotSynced bool) *externalapi.DomainBlock {
|
||||||
tryCount := 0
|
tryCount := 0
|
||||||
|
|
||||||
|
const sleepTime = 500 * time.Millisecond
|
||||||
|
const sleepTimeWhenNotSynced = 5 * time.Second
|
||||||
|
|
||||||
for {
|
for {
|
||||||
tryCount++
|
tryCount++
|
||||||
const sleepTime = 500 * time.Millisecond
|
|
||||||
shouldLog := (tryCount-1)%10 == 0
|
shouldLog := (tryCount-1)%10 == 0
|
||||||
template, isSynced := templatemanager.Get()
|
template, isSynced := templatemanager.Get()
|
||||||
if template == nil {
|
if template == nil {
|
||||||
@ -171,7 +176,7 @@ func getBlockForMining(mineWhenNotSynced bool) *externalapi.DomainBlock {
|
|||||||
if shouldLog {
|
if shouldLog {
|
||||||
log.Warnf("Kaspad is not synced. Skipping current block template")
|
log.Warnf("Kaspad is not synced. Skipping current block template")
|
||||||
}
|
}
|
||||||
time.Sleep(sleepTime)
|
time.Sleep(sleepTimeWhenNotSynced)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user