Skip to content

Commit

Permalink
Merge pull request ethereum-optimism#4790 from ethereum-optimism/jg/f…
Browse files Browse the repository at this point in the history
…ix_disable_p2p

op-node: Fix disable p2p
  • Loading branch information
mergify[bot] authored Jan 26, 2023
2 parents f3f9960 + f75aae3 commit 9be7933
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion op-node/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func RollupNodeMain(ctx *cli.Context) error {

if cfg.Heartbeat.Enabled {
var peerID string
if cfg.P2P == nil {
if cfg.P2P.Disabled() {
peerID = "disabled"
} else {
peerID = n.P2P().Host().ID().String()
Expand Down
5 changes: 5 additions & 0 deletions op-node/p2p/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var DefaultBootnodes = []*enode.Node{
// SetupP2P provides a host and discovery service for usage in the rollup node.
type SetupP2P interface {
Check() error
Disabled() bool
// Host creates a libp2p host service. Returns nil, nil if p2p is disabled.
Host(log log.Logger, reporter metrics.Reporter) (host.Host, error)
// Discovery creates a disc-v5 service. Returns nil, nil, nil if discovery is disabled.
Expand Down Expand Up @@ -134,6 +135,10 @@ func (conf *Config) TargetPeers() uint {
return conf.PeersLo
}

func (conf *Config) Disabled() bool {
return conf.DisableP2P
}

const maxMeshParam = 1000

func (conf *Config) Check() error {
Expand Down
4 changes: 4 additions & 0 deletions op-node/p2p/prepared.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,7 @@ func (p *Prepared) Discovery(log log.Logger, rollupCfg *rollup.Config, tcpPort u
func (p *Prepared) ConfigureGossip(params *pubsub.GossipSubParams) []pubsub.Option {
return nil
}

func (p *Prepared) Disabled() bool {
return false
}

0 comments on commit 9be7933

Please sign in to comment.