From 124e004bd564c141918ecf82f0cd64d3c750d507 Mon Sep 17 00:00:00 2001 From: Enrique Jose Avila Asapche <eavilaasapche@gmail.com> Date: Wed, 25 May 2022 13:49:26 +0100 Subject: [PATCH] fixed stuck dev chain (#4261) --- turbo/stages/stageloop.go | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/turbo/stages/stageloop.go b/turbo/stages/stageloop.go index bb00b8ac7b..d303850eff 100644 --- a/turbo/stages/stageloop.go +++ b/turbo/stages/stageloop.go @@ -45,10 +45,21 @@ func StageLoop( initialCycle := true for { - select { - case <-ctx.Done(): - return - default: + if !hd.POSSync() { + // Wait for delivery of any p2p headers here to resume the stage loop + // Since StageLoopStep creates RW database transaction, the mining loop can only do its work (it also requires creating RW transaction) + // when the control flow is outside StageLoopStep function. Therefore wait here to give mining loop this opportunity + select { + case <-ctx.Done(): + return + case <-hd.DeliveryNotify: + } + } else { + select { + case <-ctx.Done(): + return + default: + } } start := time.Now() @@ -102,16 +113,6 @@ func StageLoop( case <-c: } } - if !hd.POSSync() { - // Wait for delivery of any p2p headers here to resume the stage loop - // Since StageLoopStep creates RW database transaction, the mining loop can only do its work (it also requires creating RW transaction) - // when the control flow is outside StageLoopStep function. Therefore wait here to give mining loop this opportunity - select { - case <-ctx.Done(): - return - case <-hd.DeliveryNotify: - } - } } } -- GitLab