Commit b90873d8 authored by Hector Sanjuan's avatar Hector Sanjuan
Browse files

Small improvements on basichost godoc comments.



License: MIT
Signed-off-by: default avatarHector Sanjuan <hector@protocol.ai>
parent a1240fdd
// 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 returns .. // RemoveStreamHandler removes 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))
} }
......
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