Documentation ¶
Index ¶
- type BasicHost
- func (h *BasicHost) Close() error
- func (h *BasicHost) Connect(ctx context.Context, pi peer.PeerInfo) error
- func (h *BasicHost) ID() peer.ID
- func (h *BasicHost) IDService() *identify.IDService
- func (h *BasicHost) Mux() *protocol.Mux
- func (h *BasicHost) Network() inet.Network
- func (h *BasicHost) NewStream(pid protocol.ID, p peer.ID) (inet.Stream, error)
- func (h *BasicHost) Peerstore() peer.Peerstore
- func (h *BasicHost) SetStreamHandler(pid protocol.ID, handler inet.StreamHandler)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicHost ¶
type BasicHost struct {
// contains filtered or unexported fields
}
func (*BasicHost) Connect ¶
Connect ensures there is a connection between this host and the peer with given peer.ID. Connect will absorb the addresses in pi into its internal peerstore. If there is not an active connection, Connect will issue a h.Network.Dial, and block until a connection is open, or an error is returned. // TODO: Relay + NAT.
func (*BasicHost) NewStream ¶
NewStream opens a new stream to given peer p, and writes a p2p/protocol header with given protocol.ID. If there is no connection to p, attempts to create one. If ProtocolID is "", writes no header. (Threadsafe)
func (*BasicHost) SetStreamHandler ¶
func (h *BasicHost) SetStreamHandler(pid protocol.ID, handler inet.StreamHandler)
SetStreamHandler sets the protocol handler on the Host's Mux. This is equivalent to:
host.Mux().SetHandler(proto, handler)
(Threadsafe)
Click to show internal directories.
Click to hide internal directories.