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
a361bf03
Commit
a361bf03
authored
Jun 09, 2018
by
Steven Allen
Browse files
check for connectedness using Connectedness
(counting open connections requires copying)
parent
a08d9e63
Changes
2
Hide whitespace changes
Inline
Side-by-side
p2p/host/basic/basic_host.go
View file @
a361bf03
...
...
@@ -384,8 +384,7 @@ func (h *BasicHost) Connect(ctx context.Context, pi pstore.PeerInfo) error {
// absorb addresses into peerstore
h
.
Peerstore
()
.
AddAddrs
(
pi
.
ID
,
pi
.
Addrs
,
pstore
.
TempAddrTTL
)
cs
:=
h
.
Network
()
.
ConnsToPeer
(
pi
.
ID
)
if
len
(
cs
)
>
0
{
if
h
.
Network
()
.
Connectedness
(
pi
.
ID
)
==
inet
.
Connected
{
return
nil
}
...
...
p2p/host/routed/routed.go
View file @
a361bf03
...
...
@@ -47,7 +47,7 @@ func Wrap(h host.Host, r Routing) *RoutedHost {
// given peer, it will use its routing system to try to find some.
func
(
rh
*
RoutedHost
)
Connect
(
ctx
context
.
Context
,
pi
pstore
.
PeerInfo
)
error
{
// first, check if we're already connected.
if
len
(
rh
.
Network
()
.
Conn
sToPeer
(
pi
.
ID
))
>
0
{
if
rh
.
Network
()
.
Conn
ectedness
(
pi
.
ID
)
==
inet
.
Connected
{
return
nil
}
...
...
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