Documentation ¶
Overview ¶
Package p2pclient provides general libp2p client functionality
This package supplies functionality to communicate raw data with libp2p peers. It is useful for building higher-level clients that process data which is sent and received by this package.
Index ¶
- Variables
- type Client
- func (c *Client) Close() error
- func (c *Client) Connect(ctx context.Context, hostname string) error
- func (c *Client) ConnectAddrs(ctx context.Context, maddrs ...multiaddr.Multiaddr) error
- func (c *Client) Self() peer.ID
- func (c *Client) SendMessage(ctx context.Context, msg proto.Message) error
- func (c *Client) SendRequest(ctx context.Context, msg proto.Message) *Response
- type Response
Constants ¶
This section is empty.
Variables ¶
var ErrReadTimeout = fmt.Errorf("timed out reading response")
ErrReadTimeout is an error that occurs when no message is read within the timeout period.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is responsible for sending requests and receiving responses to and from libp2p peers. Each instance of Client communicates with a single peer using a single protocolID.
func New ¶
New creates a new Client that communicates with a specific peer identified by protocolID. If host is nil, then one is created.
func (*Client) Connect ¶
Connect connects the client to the host at the location specified by hostname. The value of hostname is a host or host:port, where the host is a hostname or IP address.
func (*Client) ConnectAddrs ¶
func (*Client) SendMessage ¶
SendMessage sends out a message.