fix: use a named deadline timer in CCC stage (#782)

This commit is contained in:
Ömer Faruk Irmak 2024-05-30 09:46:05 +03:00 committed by GitHub
parent ab349d6443
commit 094a67a179
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View file

@ -24,7 +24,7 @@ import (
const (
VersionMajor = 5 // Major version component of the current release
VersionMinor = 3 // Minor version component of the current release
VersionPatch = 28 // Patch version component of the current release
VersionPatch = 29 // Patch version component of the current release
VersionMeta = "mainnet" // Version metadata to append to the version string
)

View file

@ -310,14 +310,16 @@ func (p *Pipeline) cccStage(candidates <-chan *BlockCandidate, deadline time.Tim
var deadlineReached bool
go func() {
deadlineTimer := time.NewTimer(time.Until(deadline))
defer func() {
close(resultCh)
deadlineTimer.Stop()
lifetimeTimer.UpdateSince(p.start)
}()
for {
idleStart := time.Now()
select {
case <-time.After(time.Until(deadline)):
case <-deadlineTimer.C:
cccIdleTimer.UpdateSince(idleStart)
// note: currently we don't allow empty blocks, but if we ever do; make sure to CCC check it first
if lastCandidate != nil {
@ -328,8 +330,6 @@ func (p *Pipeline) cccStage(candidates <-chan *BlockCandidate, deadline time.Tim
return
}
deadlineReached = true
// avoid deadline case being triggered again and again
deadline = time.Now().Add(time.Hour)
case candidate := <-candidates:
cccIdleTimer.UpdateSince(idleStart)
cccStart := time.Now()