Documentation ¶
Index ¶
- func WithBootNodes(nodes []multiaddr.Multiaddr) func(*Config)
- func WithConnectionThreshold(n uint) func(*Config)
- func WithDialBackAddress(a string) func(*Config)
- func WithDialBackPeers(peers []blockless.Peer) func(*Config)
- func WithDialBackPeersLimit(n uint) func(*Config)
- func WithDialBackPort(n uint) func(*Config)
- func WithDialBackWebsocketPort(n uint) func(*Config)
- func WithDiscoveryInterval(d time.Duration) func(*Config)
- func WithPrivateKey(filepath string) func(*Config)
- func WithWebsocket(b bool) func(*Config)
- func WithWebsocketPort(port uint) func(*Config)
- type Config
- type Host
- func (h *Host) Addresses() []string
- func (h *Host) DiscoverPeers(ctx context.Context, topic string) error
- func (h *Host) PrivateKey() crypto.PrivKey
- func (h *Host) PublicKey() crypto.PubKey
- func (h *Host) Publish(ctx context.Context, topic *pubsub.Topic, payload []byte) error
- func (h *Host) SendMessage(ctx context.Context, to peer.ID, payload []byte) error
- func (h *Host) SendMessageOnProtocol(ctx context.Context, to peer.ID, payload []byte, protocol protocol.ID) error
- func (h *Host) Subscribe(ctx context.Context, topic string) (*pubsub.Topic, *pubsub.Subscription, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithBootNodes ¶
func WithBootNodes(nodes []multiaddr.Multiaddr) func(*Config)
WithBootNodes specifies boot nodes that the host initially tries to connect to.
func WithConnectionThreshold ¶
WithConnectionThreshold specifies how many connections should the host wait for on peer discovery.
func WithDialBackAddress ¶
func WithDialBackPeers ¶
WithDialBackPeers specifies dial-back peers that the host initially tries to connect to.
func WithDialBackPeersLimit ¶
WithDialBackPeersLimit specifies the maximum number of dial-back peers to use.
func WithDialBackPort ¶
func WithDiscoveryInterval ¶
WithDiscoveryInterval specifies how often we should try to discover new peers during the discovery phase.
func WithPrivateKey ¶
WithPrivateKey specifies the private key for the Host.
func WithWebsocket ¶
WithWebsocket specifies whether libp2p host should use websocket protocol.
func WithWebsocketPort ¶
WithWebsocketPort specifies on which port the host should listen for websocket connections.
Types ¶
type Config ¶
type Config struct { PrivateKey string ConnectionThreshold uint BootNodes []multiaddr.Multiaddr DialBackPeers []blockless.Peer DialBackPeersLimit uint DiscoveryInterval time.Duration Websocket bool WebsocketPort uint DialBackAddress string DialBackPort uint DialBackWebsocketPort uint }
Config represents the Host configuration.
type Host ¶
Host represents a new libp2p host.
func (*Host) PrivateKey ¶ added in v0.3.0
PrivateKey returns the private key of the libp2p host.
func (*Host) SendMessage ¶
SendMessage sends a message directly to the specified peer, on the standard blockless protocol.