basichost

package
v0.0.0-...-2963f48 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2015 License: MIT Imports: 7 Imported by: 0

Documentation

Index

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 New

func New(net inet.Network) *BasicHost

New constructs and sets up a new *BasicHost with given Network

func (*BasicHost) Close

func (h *BasicHost) Close() error

Close shuts down the Host's services (network, etc).

func (*BasicHost) Connect

func (h *BasicHost) Connect(ctx context.Context, pi peer.PeerInfo) error

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) ID

func (h *BasicHost) ID() peer.ID

ID returns the (local) peer.ID associated with this Host

func (*BasicHost) IDService

func (h *BasicHost) IDService() *identify.IDService

func (*BasicHost) Mux

func (h *BasicHost) Mux() *protocol.Mux

Mux returns the Mux multiplexing incoming streams to protocol handlers

func (*BasicHost) Network

func (h *BasicHost) Network() inet.Network

Networks returns the Network interface of the Host

func (*BasicHost) NewStream

func (h *BasicHost) NewStream(pid protocol.ID, p peer.ID) (inet.Stream, error)

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) Peerstore

func (h *BasicHost) Peerstore() peer.Peerstore

Peerstore returns the Host's repository of Peer Addresses and Keys.

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL