Unverified Commit a35db1d1 authored by vyzo's avatar vyzo Committed by GitHub

Merge pull request #44 from libp2p/feat/connmgr-option

add WithConnectionManager option to blankhost
parents 0fd46319 d685d71a
......@@ -36,10 +36,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(),
}
......
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