Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return Nil Error if Pre-Genesis in P2P Service Healthz Check #5355

Merged
merged 6 commits into from
Apr 8, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions beacon-chain/p2p/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type Service struct {
cfg *Config
startupErr error
dv5Listener Listener
isPreGenesis bool // Variable determining if the chain is pre-genesis.
rauljordan marked this conversation as resolved.
Show resolved Hide resolved
host host.Host
pubsub *pubsub.PubSub
exclusionList *ristretto.Cache
Expand Down Expand Up @@ -98,6 +99,7 @@ func NewService(cfg *Config) (*Service, error) {
cancel: cancel,
cfg: cfg,
exclusionList: cache,
isPreGenesis: true,
}

dv5Nodes, kadDHTNodes := parseBootStrapAddrs(s.cfg.BootstrapNodeAddr)
Expand Down Expand Up @@ -181,8 +183,10 @@ func (s *Service) Start() {
if genesisState != nil {
s.genesisTime = time.Unix(int64(genesisState.GenesisTime()), 0)
s.genesisValidatorsRoot = genesisState.GenesisValidatorRoot()
s.isPreGenesis = false
} else {
s.awaitStateInitialized()
s.isPreGenesis = false
}
rauljordan marked this conversation as resolved.
Show resolved Hide resolved

var peersToWatch []string
Expand Down Expand Up @@ -295,6 +299,9 @@ func (s *Service) Stop() error {
// Status of the p2p service. Will return an error if the service is considered unhealthy to
// indicate that this node should not serve traffic until the issue has been resolved.
func (s *Service) Status() error {
if s.isPreGenesis {
return nil
}
if !s.started {
return errors.New("not running")
}
rauljordan marked this conversation as resolved.
Show resolved Hide resolved
Expand Down