diff --git a/p2p/host/blank/blank.go b/p2p/host/blank/blank.go index b98b2e5247..162e06ac8e 100644 --- a/p2p/host/blank/blank.go +++ b/p2p/host/blank/blank.go @@ -33,10 +33,29 @@ type BlankHost struct { } } -func NewBlankHost(n network.Network) *BlankHost { +type config struct { + cmgr connmgr.ConnManager +} + +type Option = func(cfg *config) + +func WithConnectionManager(cmgr connmgr.ConnManager) Option { + return func(cfg *config) { + cfg.cmgr = cmgr + } +} + +func NewBlankHost(n network.Network, options ...Option) *BlankHost { + cfg := config{ + cmgr: &connmgr.NullConnMgr{}, + } + for _, opt := range options { + opt(&cfg) + } + bh := &BlankHost{ n: n, - cmgr: &connmgr.NullConnMgr{}, + cmgr: cfg.cmgr, mux: mstream.NewMultistreamMuxer(), eventbus: eventbus.NewBus(), }