Delay starting node until Genesis time (#2389)

This commit is contained in:
Zarko Milosevic
2018-09-18 11:16:50 +02:00
committed by Anton Kaliaev
parent 64fc8f8157
commit 2fbf810cd8
3 changed files with 26 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import (
"fmt"
"net"
"net/http"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
@ -37,6 +38,7 @@ import (
"github.com/tendermint/tendermint/state/txindex/kv"
"github.com/tendermint/tendermint/state/txindex/null"
"github.com/tendermint/tendermint/types"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/tendermint/tendermint/version"
_ "net/http/pprof"
@ -427,6 +429,13 @@ func NewNode(config *cfg.Config,
// OnStart starts the Node. It implements cmn.Service.
func (n *Node) OnStart() error {
now := tmtime.Now()
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))
}
err := n.eventBus.Start()
if err != nil {
return err