package host
Import Path
github.com/libp2p/go-libp2p/core/host (on go.dev )
Dependency Relation
imports 8 packages , and imported by 17 packages
Package-Level Type Names (only one)
/* sort by: alphabet | popularity */
type Host (interface)
Host is an object participating in a p2p network, which
implements protocols or provides services. It handles
requests like a Server, and issues requests like a Client.
It is called Host because it is both Server and Client (and Peer
may be confusing).
Methods (total 13 )
( Host) Addrs () []ma .Multiaddr
Addrs returns the listen addresses of the Host
( Host) Close () error
Close shuts down the host, its Network, and services.
( Host) ConnManager () connmgr .ConnManager
ConnManager returns this hosts connection manager
( Host) Connect (ctx context .Context , pi peer .AddrInfo ) 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.
( Host) EventBus () event .Bus
EventBus returns the hosts eventbus
( Host) ID () peer .ID
ID returns the (local) peer.ID associated with this Host
( Host) Mux () protocol .Switch
Mux returns the Mux multiplexing incoming streams to protocol handlers
( Host) Network () network .Network
Network returns the Network interface of the Host
( Host) NewStream (ctx context .Context , p peer .ID , pids ...protocol .ID ) (network .Stream , error )
NewStream opens a new stream to given peer p, and writes a p2p/protocol
header with given ProtocolID. If there is no connection to p, attempts
to create one. If ProtocolID is "", writes no header.
(Thread-safe)
( Host) Peerstore () peerstore .Peerstore
Peerstore returns the Host's repository of Peer Addresses and Keys.
( Host) RemoveStreamHandler (pid protocol .ID )
RemoveStreamHandler removes a handler on the mux that was set by
SetStreamHandler
( Host) SetStreamHandler (pid protocol .ID , handler network .StreamHandler )
SetStreamHandler sets the protocol handler on the Host's Mux.
This is equivalent to:
host.Mux().SetHandler(proto, handler)
(Thread-safe)
( Host) SetStreamHandlerMatch (protocol .ID , func(protocol .ID ) bool , network .StreamHandler )
SetStreamHandlerMatch sets the protocol handler on the Host's Mux
using a matching function for protocol selection.
Implemented By (at least 3 )
*github.com/libp2p/go-libp2p/p2p/host/basic.BasicHost
*github.com/libp2p/go-libp2p/p2p/host/blank.BlankHost
*github.com/libp2p/go-libp2p/p2p/host/routed.RoutedHost
Implements (at least 2 )
Host : github.com/prometheus/common/expfmt.Closer
Host : io.Closer
As Outputs Of (at least 3 )
func github.com/libp2p/go-libp2p.New (opts ...libp2p .Option ) (Host , error )
func github.com/libp2p/go-libp2p.NewWithoutDefaults (opts ...libp2p .Option ) (Host , error )
func github.com/libp2p/go-libp2p/config.(*Config ).NewNode () (Host , error )
As Inputs Of (at least 25 )
func InfoFromHost (h Host ) *peer .AddrInfo
func github.com/libp2p/go-libp2p/p2p/discovery/backoff.NewBackoffConnector (h Host , cacheSize int , connectionTryDuration time .Duration , backoff backoff .BackoffFactory ) (*backoff .BackoffConnector , error )
func github.com/libp2p/go-libp2p/p2p/host/autonat.New (h Host , options ...autonat .Option ) (autonat .AutoNAT , error )
func github.com/libp2p/go-libp2p/p2p/host/autonat.NewAutoNATClient (h Host , addrFunc autonat .AddrFunc , mt autonat .MetricsTracer ) autonat .Client
func github.com/libp2p/go-libp2p/p2p/host/autorelay.NewAutoRelay (host Host , opts ...autorelay .Option ) (*autorelay .AutoRelay , error )
func github.com/libp2p/go-libp2p/p2p/host/relaysvc.NewRelayManager (host Host , opts ...relayv2 .Option ) *relaysvc .RelayManager
func github.com/libp2p/go-libp2p/p2p/host/routed.Wrap (h Host , r routedhost .Routing ) *routedhost .RoutedHost
func github.com/libp2p/go-libp2p/p2p/protocol/autonatv2.New (dialerHost Host , opts ...autonatv2 .AutoNATOption ) (*autonatv2 .AutoNAT , error )
func github.com/libp2p/go-libp2p/p2p/protocol/autonatv2.(*AutoNAT ).Start (h Host ) error
func github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/client.AddTransport (h Host , upgrader transport .Upgrader ) error
func github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/client.New (h Host , upgrader transport .Upgrader ) (*client .Client , error )
func github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/client.Reserve (ctx context .Context , h Host , ai peer .AddrInfo ) (*client .Reservation , error )
func github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/relay.New (h Host , opts ...relay .Option ) (*relay .Relay , error )
func github.com/libp2p/go-libp2p/p2p/protocol/holepunch.NewService (h Host , ids identify .IDService , listenAddrs func() []ma .Multiaddr , opts ...holepunch .Option ) (*holepunch .Service , error )
func github.com/libp2p/go-libp2p/p2p/protocol/identify.NewIDService (h Host , opts ...identify .Option ) (*identify .idService , error )
func github.com/libp2p/go-libp2p/p2p/protocol/ping.NewPingService (h Host ) *ping .PingService
func github.com/libp2p/go-libp2p/p2p/protocol/ping.Ping (ctx context .Context , h Host , p peer .ID ) <-chan ping .Result
func github.com/libp2p/go-libp2p-pubsub.DefaultGossipSubRouter (h Host ) *pubsub .GossipSubRouter
func github.com/libp2p/go-libp2p-pubsub.NewFloodSub (ctx context .Context , h Host , opts ...pubsub .Option ) (*pubsub .PubSub , error )
func github.com/libp2p/go-libp2p-pubsub.NewFloodsubWithProtocols (ctx context .Context , h Host , ps []protocol .ID , opts ...pubsub .Option ) (*pubsub .PubSub , error )
func github.com/libp2p/go-libp2p-pubsub.NewGossipSub (ctx context .Context , h Host , opts ...pubsub .Option ) (*pubsub .PubSub , error )
func github.com/libp2p/go-libp2p-pubsub.NewGossipSubWithRouter (ctx context .Context , h Host , rt pubsub .PubSubRouter , opts ...pubsub .Option ) (*pubsub .PubSub , error )
func github.com/libp2p/go-libp2p-pubsub.NewPubSub (ctx context .Context , h Host , rt pubsub .PubSubRouter , opts ...pubsub .Option ) (*pubsub .PubSub , error )
func github.com/libp2p/go-libp2p-pubsub.NewRandomSub (ctx context .Context , h Host , size int , opts ...pubsub .Option ) (*pubsub .PubSub , error )
func github.com/libp2p/go-libp2p-pubsub.NewRemoteTracer (ctx context .Context , host Host , pi peer .AddrInfo ) (*pubsub .RemoteTracer , error )
Package-Level Functions (only one)
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .