mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
fix: use a named deadline timer in CCC stage (#782)
This commit is contained in:
parent
ab349d6443
commit
094a67a179
2 changed files with 4 additions and 4 deletions
|
|
@ -24,7 +24,7 @@ import (
|
||||||
const (
|
const (
|
||||||
VersionMajor = 5 // Major version component of the current release
|
VersionMajor = 5 // Major version component of the current release
|
||||||
VersionMinor = 3 // Minor 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
|
VersionMeta = "mainnet" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -310,14 +310,16 @@ func (p *Pipeline) cccStage(candidates <-chan *BlockCandidate, deadline time.Tim
|
||||||
var deadlineReached bool
|
var deadlineReached bool
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
deadlineTimer := time.NewTimer(time.Until(deadline))
|
||||||
defer func() {
|
defer func() {
|
||||||
close(resultCh)
|
close(resultCh)
|
||||||
|
deadlineTimer.Stop()
|
||||||
lifetimeTimer.UpdateSince(p.start)
|
lifetimeTimer.UpdateSince(p.start)
|
||||||
}()
|
}()
|
||||||
for {
|
for {
|
||||||
idleStart := time.Now()
|
idleStart := time.Now()
|
||||||
select {
|
select {
|
||||||
case <-time.After(time.Until(deadline)):
|
case <-deadlineTimer.C:
|
||||||
cccIdleTimer.UpdateSince(idleStart)
|
cccIdleTimer.UpdateSince(idleStart)
|
||||||
// note: currently we don't allow empty blocks, but if we ever do; make sure to CCC check it first
|
// note: currently we don't allow empty blocks, but if we ever do; make sure to CCC check it first
|
||||||
if lastCandidate != nil {
|
if lastCandidate != nil {
|
||||||
|
|
@ -328,8 +330,6 @@ func (p *Pipeline) cccStage(candidates <-chan *BlockCandidate, deadline time.Tim
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
deadlineReached = true
|
deadlineReached = true
|
||||||
// avoid deadline case being triggered again and again
|
|
||||||
deadline = time.Now().Add(time.Hour)
|
|
||||||
case candidate := <-candidates:
|
case candidate := <-candidates:
|
||||||
cccIdleTimer.UpdateSince(idleStart)
|
cccIdleTimer.UpdateSince(idleStart)
|
||||||
cccStart := time.Now()
|
cccStart := time.Now()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue