Documentation ¶
Index ¶
- func ConnectednessToString(connectedness network.Connectedness) (string, bool)
- func CountStream(host host.Host, targetID peer.ID, opts ...FilterOption) int
- func DirectionToString(direction network.Direction) (string, bool)
- func FilterStream(host host.Host, targetID peer.ID, options ...FilterOption) []network.Stream
- func FlowStream(conn network.Conn) network.Stream
- func IPPortFromMultiAddress(addrs ...multiaddr.Multiaddr) (string, string, error)
- func NetworkingInfo(identity flow.Identity) (string, string, crypto.PubKey, error)
- func StreamLogger(log zerolog.Logger, stream network.Stream) zerolog.Logger
- type FilterOption
- type FilterOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectednessToString ¶
func ConnectednessToString(connectedness network.Connectedness) (string, bool)
ConnectednessToString reverse translates libp2p network connectedness to string
func CountStream ¶
CountStream finds total number of outbound stream to the target id
func DirectionToString ¶
DirectionToString reverse translates libp2p network direction to string
func FilterStream ¶
FilterStream filters the streams to a target peer based on the provided options. The default behavior is to consider all directions and protocols, and return just the first matching stream. This behavior can be customized by providing FilterOption values.
Usage:
To find all outbound streams to a target peer with a specific protocol ID: streams := FilterStream(host, targetID, Direction(network.DirOutbound), Protocol(myProtocolID), All(true))
To find the first inbound stream to a target peer, regardless of protocol ID: stream := FilterStream(host, targetID, Direction(network.DirInbound))
host is the host from which to filter streams. targetID is the ID of the target peer. options is a variadic parameter that allows zero or more FilterOption values to be provided.
It returns a slice of network.Stream values that match the filtering criteria.
func FlowStream ¶
FlowStream returns the Flow protocol Stream in the connection if one exist, else it returns nil
func IPPortFromMultiAddress ¶
IPPortFromMultiAddress returns the IP/hostname and the port for the given multi-addresses associated with a libp2p host
func NetworkingInfo ¶
NetworkingInfo returns ip, port, libp2p public key of the identity.
Types ¶
type FilterOption ¶ added in v0.32.3
type FilterOption func(*FilterOptions)
FilterOption defines a function type that modifies FilterOptions.
func All ¶ added in v0.32.3
func All() FilterOption
All is a FilterOption for setting whether to return all matching streams or just the first matching stream.
func Direction ¶ added in v0.32.3
func Direction(dir network.Direction) FilterOption
Direction is a FilterOption for setting the direction of the streams to be filtered.
func Protocol ¶ added in v0.32.3
func Protocol(protocol protocol.ID) FilterOption
Protocol is a FilterOption for setting the protocol ID of the streams to be filtered.
type FilterOptions ¶ added in v0.32.3
type FilterOptions struct {
// contains filtered or unexported fields
}
FilterOptions holds the filtering options used in FilterStream.