Commit c75dc450 authored by Adrian Sutton's avatar Adrian Sutton

op-node: Remove ConnGater and ConnMngr constructors from p2p config

The config was calling these itself from the Host method and nothing actually used the ability to further customize them.
parent 9afd5c7b
...@@ -70,9 +70,6 @@ func NewConfig(ctx *cli.Context, blockTime uint64) (*p2p.Config, error) { ...@@ -70,9 +70,6 @@ func NewConfig(ctx *cli.Context, blockTime uint64) (*p2p.Config, error) {
return nil, fmt.Errorf("failed to load p2p topic scoring options: %w", err) return nil, fmt.Errorf("failed to load p2p topic scoring options: %w", err)
} }
conf.ConnGater = p2p.DefaultConnGater
conf.ConnMngr = p2p.DefaultConnManager
conf.EnableReqRespSync = ctx.GlobalBool(flags.SyncReqRespFlag.Name) conf.EnableReqRespSync = ctx.GlobalBool(flags.SyncReqRespFlag.Name)
return conf, nil return conf, nil
......
...@@ -106,9 +106,6 @@ type Config struct { ...@@ -106,9 +106,6 @@ type Config struct {
// Underlying store that hosts connection-gater and peerstore data. // Underlying store that hosts connection-gater and peerstore data.
Store ds.Batching Store ds.Batching
ConnGater func(conf *Config) (connmgr.ConnectionGater, error)
ConnMngr func(conf *Config) (connmgr.ConnManager, error)
EnableReqRespSync bool EnableReqRespSync bool
} }
...@@ -193,12 +190,6 @@ func (conf *Config) Check() error { ...@@ -193,12 +190,6 @@ func (conf *Config) Check() error {
if conf.PeersLo == 0 || conf.PeersHi == 0 || conf.PeersLo > conf.PeersHi { if conf.PeersLo == 0 || conf.PeersHi == 0 || conf.PeersLo > conf.PeersHi {
return fmt.Errorf("peers lo/hi tides are invalid: %d, %d", conf.PeersLo, conf.PeersHi) return fmt.Errorf("peers lo/hi tides are invalid: %d, %d", conf.PeersLo, conf.PeersHi)
} }
if conf.ConnMngr == nil {
return errors.New("need a connection manager")
}
if conf.ConnGater == nil {
return errors.New("need a connection gater")
}
if conf.MeshD <= 0 || conf.MeshD > maxMeshParam { if conf.MeshD <= 0 || conf.MeshD > maxMeshParam {
return fmt.Errorf("mesh D param must not be 0 or exceed %d, but got %d", maxMeshParam, conf.MeshD) return fmt.Errorf("mesh D param must not be 0 or exceed %d, but got %d", maxMeshParam, conf.MeshD)
} }
......
...@@ -144,12 +144,12 @@ func (conf *Config) Host(log log.Logger, reporter metrics.Reporter) (host.Host, ...@@ -144,12 +144,12 @@ func (conf *Config) Host(log log.Logger, reporter metrics.Reporter) (host.Host,
return nil, fmt.Errorf("failed to set up peerstore with pub key: %w", err) return nil, fmt.Errorf("failed to set up peerstore with pub key: %w", err)
} }
connGtr, err := conf.ConnGater(conf) connGtr, err := DefaultConnGater(conf)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to open connection gater: %w", err) return nil, fmt.Errorf("failed to open connection gater: %w", err)
} }
connMngr, err := conf.ConnMngr(conf) connMngr, err := DefaultConnManager(conf)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to open connection manager: %w", err) return nil, fmt.Errorf("failed to open connection manager: %w", err)
} }
......
...@@ -12,12 +12,10 @@ import ( ...@@ -12,12 +12,10 @@ import (
ds "github.com/ipfs/go-datastore" ds "github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/sync" "github.com/ipfs/go-datastore/sync"
"github.com/libp2p/go-libp2p" "github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p/core/connmgr"
"github.com/libp2p/go-libp2p/core/crypto" "github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer" "github.com/libp2p/go-libp2p/core/peer"
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
tswarm "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/exp/slices" "golang.org/x/exp/slices"
...@@ -54,10 +52,6 @@ func TestingConfig(t *testing.T) *Config { ...@@ -54,10 +52,6 @@ func TestingConfig(t *testing.T) *Config {
TimeoutAccept: time.Second * 2, TimeoutAccept: time.Second * 2,
TimeoutDial: time.Second * 2, TimeoutDial: time.Second * 2,
Store: sync.MutexWrap(ds.NewMapDatastore()), Store: sync.MutexWrap(ds.NewMapDatastore()),
ConnGater: func(conf *Config) (connmgr.ConnectionGater, error) {
return tswarm.DefaultMockConnectionGater(), nil
},
ConnMngr: DefaultConnManager,
} }
} }
...@@ -113,8 +107,6 @@ func TestP2PFull(t *testing.T) { ...@@ -113,8 +107,6 @@ func TestP2PFull(t *testing.T) {
TimeoutAccept: time.Second * 2, TimeoutAccept: time.Second * 2,
TimeoutDial: time.Second * 2, TimeoutDial: time.Second * 2,
Store: sync.MutexWrap(ds.NewMapDatastore()), Store: sync.MutexWrap(ds.NewMapDatastore()),
ConnGater: DefaultConnGater,
ConnMngr: DefaultConnManager,
} }
// copy config A, and change the settings for B // copy config A, and change the settings for B
confB := confA confB := confA
...@@ -262,8 +254,6 @@ func TestDiscovery(t *testing.T) { ...@@ -262,8 +254,6 @@ func TestDiscovery(t *testing.T) {
TimeoutDial: time.Second * 2, TimeoutDial: time.Second * 2,
Store: sync.MutexWrap(ds.NewMapDatastore()), Store: sync.MutexWrap(ds.NewMapDatastore()),
DiscoveryDB: discDBA, DiscoveryDB: discDBA,
ConnGater: DefaultConnGater,
ConnMngr: DefaultConnManager,
} }
// copy config A, and change the settings for B // copy config A, and change the settings for B
confB := confA confB := confA
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment