Browse Source

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

pull/7839/head
Sam Kleinman 3 years ago
committed by GitHub
parent
commit
cbb2c1d3bd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions
  1. +8
    -1
      node/node.go

+ 8
- 1
node/node.go 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


Loading…
Cancel
Save