Commit d685d71a authored by Yusef Napora's avatar Yusef Napora

add WithConnectionManager option to blankhost

parent c2cbee27
...@@ -33,10 +33,29 @@ type BlankHost struct { ...@@ -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{ bh := &BlankHost{
n: n, n: n,
cmgr: &connmgr.NullConnMgr{}, cmgr: cfg.cmgr,
mux: mstream.NewMultistreamMuxer(), mux: mstream.NewMultistreamMuxer(),
eventbus: eventbus.NewBus(), eventbus: eventbus.NewBus(),
} }
......
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