node: allow orderly shutdown if context is canceled and gensis is in the future (#7817)

This commit is contained in:
Sam Kleinman
2022-02-17 08:07:44 -05:00
committed by GitHub
parent 94b409e407
commit cbb2c1d3bd

View File

@@ -441,7 +441,14 @@ func (n *nodeImpl) OnStart(ctx context.Context) error {
genTime := n.genesisDoc.GenesisTime
if genTime.After(now) {
n.logger.Info("Genesis time is in the future. Sleeping until then...", "genTime", genTime)
time.Sleep(genTime.Sub(now))
timer := time.NewTimer(genTime.Sub(now))
defer timer.Stop()
select {
case <-ctx.Done():
return ctx.Err()
case <-timer.C:
}
}
// Start the RPC server before the P2P server