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
0fa1c254
Commit
0fa1c254
authored
Oct 19, 2018
by
vyzo
Browse files
ping service in basic host
parent
a768598c
Changes
1
Hide whitespace changes
Inline
Side-by-side
p2p/host/basic/basic_host.go
View file @
0fa1c254
...
...
@@ -14,6 +14,7 @@ import (
pstore
"github.com/libp2p/go-libp2p-peerstore"
protocol
"github.com/libp2p/go-libp2p-protocol"
identify
"github.com/libp2p/go-libp2p/p2p/protocol/identify"
ping
"github.com/libp2p/go-libp2p/p2p/protocol/ping"
ma
"github.com/multiformats/go-multiaddr"
madns
"github.com/multiformats/go-multiaddr-dns"
msmux
"github.com/multiformats/go-multistream"
...
...
@@ -56,6 +57,7 @@ type BasicHost struct {
network
inet
.
Network
mux
*
msmux
.
MultistreamMuxer
ids
*
identify
.
IDService
pings
*
ping
.
PingService
natmgr
NATManager
addrs
AddrsFactory
maResolver
*
madns
.
Resolver
...
...
@@ -96,6 +98,9 @@ type HostOpts struct {
// ConnManager is a libp2p connection manager
ConnManager
ifconnmgr
.
ConnManager
// EnablePing indicates whether to instantiate the ping service
EnablePing
bool
}
// NewHost constructs a new *BasicHost and activates it by attaching its stream and connection handlers to the given inet.Network.
...
...
@@ -149,6 +154,10 @@ func NewHost(ctx context.Context, net inet.Network, opts *HostOpts) (*BasicHost,
net
.
Notify
(
h
.
cmgr
.
Notifee
())
}
if
opts
.
EnablePing
{
h
.
pings
=
ping
.
NewPingService
(
h
)
}
net
.
SetConnHandler
(
h
.
newConnHandler
)
net
.
SetStreamHandler
(
h
.
newStreamHandler
)
return
h
,
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