Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
85d0247d
Commit
85d0247d
authored
Oct 06, 2017
by
Jeromy
Browse files
use connmgr interface instead of connmgr directly
parent
542b0662
Changes
3
Hide whitespace changes
Inline
Side-by-side
p2p/host/basic/basic_host.go
View file @
85d0247d
...
@@ -10,7 +10,7 @@ import (
...
@@ -10,7 +10,7 @@ import (
logging
"github.com/ipfs/go-log"
logging
"github.com/ipfs/go-log"
goprocess
"github.com/jbenet/goprocess"
goprocess
"github.com/jbenet/goprocess"
circuit
"github.com/libp2p/go-libp2p-circuit"
circuit
"github.com/libp2p/go-libp2p-circuit"
connmgr
"github.com/libp2p/go-libp2p-connmgr"
if
connmgr
"github.com/libp2p/go-libp2p-
interface-
connmgr"
metrics
"github.com/libp2p/go-libp2p-metrics"
metrics
"github.com/libp2p/go-libp2p-metrics"
mstream
"github.com/libp2p/go-libp2p-metrics/stream"
mstream
"github.com/libp2p/go-libp2p-metrics/stream"
inet
"github.com/libp2p/go-libp2p-net"
inet
"github.com/libp2p/go-libp2p-net"
...
@@ -62,7 +62,7 @@ type BasicHost struct {
...
@@ -62,7 +62,7 @@ type BasicHost struct {
natmgr
NATManager
natmgr
NATManager
addrs
AddrsFactory
addrs
AddrsFactory
maResolver
*
madns
.
Resolver
maResolver
*
madns
.
Resolver
cmgr
connmgr
.
ConnManager
cmgr
if
connmgr
.
ConnManager
negtimeout
time
.
Duration
negtimeout
time
.
Duration
...
@@ -104,7 +104,7 @@ type HostOpts struct {
...
@@ -104,7 +104,7 @@ type HostOpts struct {
BandwidthReporter
metrics
.
Reporter
BandwidthReporter
metrics
.
Reporter
// ConnManager is a libp2p connection manager
// ConnManager is a libp2p connection manager
ConnManager
connmgr
.
ConnManager
ConnManager
if
connmgr
.
ConnManager
// Relay indicates whether the host should use circuit relay transport
// Relay indicates whether the host should use circuit relay transport
EnableRelay
bool
EnableRelay
bool
...
@@ -156,10 +156,10 @@ func NewHost(ctx context.Context, net inet.Network, opts *HostOpts) (*BasicHost,
...
@@ -156,10 +156,10 @@ func NewHost(ctx context.Context, net inet.Network, opts *HostOpts) (*BasicHost,
}
}
if
opts
.
ConnManager
==
nil
{
if
opts
.
ConnManager
==
nil
{
// create 'disabled' conn manager for now
h
.
cmgr
=
&
ifconnmgr
.
NullConnMgr
{}
h
.
cmgr
=
connmgr
.
NewConnManager
(
0
,
0
,
0
)
}
else
{
}
else
{
h
.
cmgr
=
opts
.
ConnManager
h
.
cmgr
=
opts
.
ConnManager
net
.
Notify
(
h
.
cmgr
.
Notifee
())
}
}
var
relayCtx
context
.
Context
var
relayCtx
context
.
Context
...
@@ -207,7 +207,7 @@ func New(net inet.Network, opts ...interface{}) *BasicHost {
...
@@ -207,7 +207,7 @@ func New(net inet.Network, opts ...interface{}) *BasicHost {
hostopts
.
BandwidthReporter
=
o
hostopts
.
BandwidthReporter
=
o
case
AddrsFactory
:
case
AddrsFactory
:
hostopts
.
AddrsFactory
=
AddrsFactory
(
o
)
hostopts
.
AddrsFactory
=
AddrsFactory
(
o
)
case
connmgr
.
ConnManager
:
case
if
connmgr
.
ConnManager
:
hostopts
.
ConnManager
=
o
hostopts
.
ConnManager
=
o
case
*
madns
.
Resolver
:
case
*
madns
.
Resolver
:
hostopts
.
MultiaddrResolver
=
o
hostopts
.
MultiaddrResolver
=
o
...
@@ -504,7 +504,7 @@ func (h *BasicHost) dialPeer(ctx context.Context, p peer.ID) error {
...
@@ -504,7 +504,7 @@ func (h *BasicHost) dialPeer(ctx context.Context, p peer.ID) error {
return
nil
return
nil
}
}
func
(
h
*
BasicHost
)
ConnManager
()
connmgr
.
ConnManager
{
func
(
h
*
BasicHost
)
ConnManager
()
if
connmgr
.
ConnManager
{
return
h
.
cmgr
return
h
.
cmgr
}
}
...
...
p2p/host/routed/routed.go
View file @
85d0247d
...
@@ -8,7 +8,7 @@ import (
...
@@ -8,7 +8,7 @@ import (
host
"github.com/libp2p/go-libp2p-host"
host
"github.com/libp2p/go-libp2p-host"
logging
"github.com/ipfs/go-log"
logging
"github.com/ipfs/go-log"
connmgr
"github.com/libp2p/go-libp2p-connmgr"
if
connmgr
"github.com/libp2p/go-libp2p-
interface-
connmgr"
lgbl
"github.com/libp2p/go-libp2p-loggables"
lgbl
"github.com/libp2p/go-libp2p-loggables"
inet
"github.com/libp2p/go-libp2p-net"
inet
"github.com/libp2p/go-libp2p-net"
peer
"github.com/libp2p/go-libp2p-peer"
peer
"github.com/libp2p/go-libp2p-peer"
...
@@ -142,7 +142,7 @@ func (rh *RoutedHost) Close() error {
...
@@ -142,7 +142,7 @@ func (rh *RoutedHost) Close() error {
// no need to close IpfsRouting. we dont own it.
// no need to close IpfsRouting. we dont own it.
return
rh
.
host
.
Close
()
return
rh
.
host
.
Close
()
}
}
func
(
rh
*
RoutedHost
)
ConnManager
()
connmgr
.
ConnManager
{
func
(
rh
*
RoutedHost
)
ConnManager
()
if
connmgr
.
ConnManager
{
return
rh
.
host
.
ConnManager
()
return
rh
.
host
.
ConnManager
()
}
}
...
...
package.json
View file @
85d0247d
...
@@ -205,9 +205,9 @@
...
@@ -205,9 +205,9 @@
},
},
{
{
"author"
:
"whyrusleeping"
,
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
aSxYRuMq4pkpBBG2CYaRrPx2z7NmMVEs34b9g61biQA6
"
,
"hash"
:
"Qm
c1XhrFEiSeBNn3mpfg6gEuYCt5im2gYmNVmncsvmpeAk
"
,
"name"
:
"go-libp2p-host"
,
"name"
:
"go-libp2p-host"
,
"version"
:
"2.
0.0
"
"version"
:
"2.
1.1
"
},
},
{
{
"author"
:
"whyrusleeping"
,
"author"
:
"whyrusleeping"
,
...
@@ -229,9 +229,9 @@
...
@@ -229,9 +229,9 @@
},
},
{
{
"author"
:
"whyrusleeping"
,
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
PZRCaYeNLMo5GfcRS2rv9ZxVuXXt6MFg9dWLmgsdXKCw
"
,
"hash"
:
"Qm
QkeGXc9ZuQ5upVFpd2EjKvgw9aVh1BbtAgvNGVcebmmX
"
,
"name"
:
"go-libp2p-blankhost"
,
"name"
:
"go-libp2p-blankhost"
,
"version"
:
"0.2.
0
"
"version"
:
"0.2.
1
"
},
},
{
{
"author"
:
"whyrusleeping"
,
"author"
:
"whyrusleeping"
,
...
@@ -257,12 +257,6 @@
...
@@ -257,12 +257,6 @@
"name"
:
"go-smux-multistream"
,
"name"
:
"go-smux-multistream"
,
"version"
:
"2.0.0"
"version"
:
"2.0.0"
},
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"QmYUpfXEBqLdtiSUDzzc8hLfcELPHiPtANF12EpEX1WCVB"
,
"name"
:
"go-libp2p-connmgr"
,
"version"
:
"0.2.0"
},
{
{
"author"
:
"whyrusleeping"
,
"author"
:
"whyrusleeping"
,
"hash"
:
"QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB"
,
"hash"
:
"QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB"
,
...
@@ -271,15 +265,21 @@
...
@@ -271,15 +265,21 @@
},
},
{
{
"author"
:
"vyzo"
,
"author"
:
"vyzo"
,
"hash"
:
"Qm
bMNjK69isbpzVGKKrsnM7Sqyh3TVKAphRn5WuUhwTFbW
"
,
"hash"
:
"Qm
fHWhmJSJD9RjogJdPsb7wzJbUkxpZkctHvAfvJCTAP6X
"
,
"name"
:
"go-libp2p-circuit"
,
"name"
:
"go-libp2p-circuit"
,
"version"
:
"2.0.
2
"
"version"
:
"2.0.
3
"
},
},
{
{
"author"
:
"lgierth"
,
"author"
:
"lgierth"
,
"hash"
:
"QmS7xUmsTdVNU2t1bPV6o9aXuXfufAjNGYgh2bcN2z9DAs"
,
"hash"
:
"QmS7xUmsTdVNU2t1bPV6o9aXuXfufAjNGYgh2bcN2z9DAs"
,
"name"
:
"go-multiaddr-dns"
,
"name"
:
"go-multiaddr-dns"
,
"version"
:
"0.2.0"
"version"
:
"0.2.0"
},
{
"author"
:
"why"
,
"hash"
:
"QmYkCrTwivapqdB3JbwvwvxymseahVkcm46ThRMAA24zCr"
,
"name"
:
"go-libp2p-interface-connmgr"
,
"version"
:
"0.0.2"
}
}
],
],
"gxVersion"
:
"0.4.0"
,
"gxVersion"
:
"0.4.0"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment