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
b90873d8
Commit
b90873d8
authored
Mar 15, 2017
by
Hector Sanjuan
Browse files
Small improvements on basichost godoc comments.
License: MIT Signed-off-by:
Hector Sanjuan
<
hector@protocol.ai
>
parent
a1240fdd
Changes
1
Hide whitespace changes
Inline
Side-by-side
p2p/host/basic/basic_host.go
View file @
b90873d8
// Package basichost provides a basic libp2p Host implementation.
package
basichost
package
basichost
import
(
import
(
...
@@ -21,6 +22,8 @@ import (
...
@@ -21,6 +22,8 @@ import (
var
log
=
logging
.
Logger
(
"basichost"
)
var
log
=
logging
.
Logger
(
"basichost"
)
// NegotiateTimeout sets a deadline to perform stream handling
// negotiation (exchange of protocol IDs)
var
NegotiateTimeout
=
time
.
Second
*
60
var
NegotiateTimeout
=
time
.
Second
*
60
// Option is a type used to pass in options to the host.
// Option is a type used to pass in options to the host.
...
@@ -53,7 +56,9 @@ type BasicHost struct {
...
@@ -53,7 +56,9 @@ type BasicHost struct {
bwc
metrics
.
Reporter
bwc
metrics
.
Reporter
}
}
// New constructs and sets up a new *BasicHost with given Network
// New constructs and sets up a new *BasicHost with given Network. It can take
// additional options. Currently NATPortMap (see "Constants"
// documentation) and a custom metrics.Reporter are supported.
func
New
(
net
inet
.
Network
,
opts
...
interface
{})
*
BasicHost
{
func
New
(
net
inet
.
Network
,
opts
...
interface
{})
*
BasicHost
{
h
:=
&
BasicHost
{
h
:=
&
BasicHost
{
network
:
net
,
network
:
net
,
...
@@ -167,12 +172,12 @@ func (h *BasicHost) Network() inet.Network {
...
@@ -167,12 +172,12 @@ func (h *BasicHost) Network() inet.Network {
return
h
.
network
return
h
.
network
}
}
// Mux returns the Mux multiplexing incoming streams to protocol handlers
// Mux returns the Mux multiplexing incoming streams to protocol handlers
.
func
(
h
*
BasicHost
)
Mux
()
*
msmux
.
MultistreamMuxer
{
func
(
h
*
BasicHost
)
Mux
()
*
msmux
.
MultistreamMuxer
{
return
h
.
mux
return
h
.
mux
}
}
// IDService returns
// IDService returns
the IDService for this host.
func
(
h
*
BasicHost
)
IDService
()
*
identify
.
IDService
{
func
(
h
*
BasicHost
)
IDService
()
*
identify
.
IDService
{
return
h
.
ids
return
h
.
ids
}
}
...
@@ -201,7 +206,7 @@ func (h *BasicHost) SetStreamHandlerMatch(pid protocol.ID, m func(string) bool,
...
@@ -201,7 +206,7 @@ func (h *BasicHost) SetStreamHandlerMatch(pid protocol.ID, m func(string) bool,
})
})
}
}
// RemoveStreamHandler re
turns .
.
// RemoveStreamHandler re
moves the handler matching the given protocol ID
.
func
(
h
*
BasicHost
)
RemoveStreamHandler
(
pid
protocol
.
ID
)
{
func
(
h
*
BasicHost
)
RemoveStreamHandler
(
pid
protocol
.
ID
)
{
h
.
Mux
()
.
RemoveHandler
(
string
(
pid
))
h
.
Mux
()
.
RemoveHandler
(
string
(
pid
))
}
}
...
...
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