Documentation ¶
Index ¶
- Constants
- type Client
- func (c *Client) Close() error
- func (c *Client) Connect(p peer.ID, addrs []multiaddr.Multiaddr) error
- func (c *Client) FindPeer(peer peer.ID) (PeerInfo, error)
- func (c *Client) FindProviders(ctx context.Context, cid cid.Cid) (<-chan PeerInfo, error)
- func (c *Client) GetClosestPeers(ctx context.Context, key []byte) (<-chan peer.ID, error)
- func (c *Client) GetPublicKey(peer peer.ID) (crypto.PubKey, error)
- func (c *Client) GetTopics() ([]string, error)
- func (c *Client) GetValue(key []byte) ([]byte, error)
- func (c *Client) Identify() (peer.ID, []multiaddr.Multiaddr, error)
- func (c *Client) ListPeers() ([]peer.ID, error)
- func (c *Client) NewStream(peer peer.ID, protos []string) (*StreamInfo, io.ReadWriteCloser, error)
- func (c *Client) NewStreamHandler(protos []string, handler StreamHandlerFunc) error
- func (c *Client) Provide(id cid.Cid) error
- func (c *Client) Publish(topic string, data []byte) error
- func (c *Client) PutValue(key []byte, value []byte) error
- func (c *Client) SearchValue(ctx context.Context, key []byte) (<-chan []byte, error)
- func (c *Client) Subscribe(ctx context.Context, topic string) (<-chan *pb.PSMessage, error)
- type PeerInfo
- type StreamHandlerFunc
- type StreamInfo
Constants ¶
const MessageSizeMax = 1 << 22 // 4 MB
MessageSizeMax is cribbed from github.com/libp2p/go-libp2p-net
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the struct that manages a connection to a libp2p daemon.
func NewClient ¶
NewClient creates a new libp2p daemon client, connecting to a daemon listening on a multi-addr at controlMaddr, and establishing an inbound listening multi-address at listenMaddr
func (*Client) Connect ¶
Connect establishes a connection to a peer after populating the Peerstore entry for said peer with a list of addresses.
func (*Client) FindProviders ¶
FindProviders queries the DHT for peers that provide a piece of content identified by a CID.
func (*Client) GetClosestPeers ¶
GetClosestPeers queries the DHT routing table for peers that are closest to a provided key.
func (*Client) GetPublicKey ¶
GetPublicKey queries the daemon for a peer's address.
func (*Client) NewStream ¶
func (c *Client) NewStream(peer peer.ID, protos []string) (*StreamInfo, io.ReadWriteCloser, error)
NewStream initializes a new stream on one of the protocols in protos with the specified peer.
func (*Client) NewStreamHandler ¶
func (c *Client) NewStreamHandler(protos []string, handler StreamHandlerFunc) error
NewStreamHandler establishes an inbound multi-address and starts a listener. All inbound connections to the listener are delegated to the provided handler.
func (*Client) PutValue ¶
PutValue sets the value stored at a given key in the DHT to a given value.
func (*Client) SearchValue ¶
SearchValue queries the DHT for the best/most valid value stored at a key. Later responses are better.
type PeerInfo ¶
type PeerInfo struct { // Id is the peer's ID ID peer.ID // Addrs are the peer's listen addresses. Addrs []ma.Multiaddr }
PeerInfo wraps the PeerInfo message from our protobuf with richer types.
type StreamHandlerFunc ¶
type StreamHandlerFunc func(*StreamInfo, io.ReadWriteCloser)
StreamHandlerFunc is the type of callbacks executed upon receiving a new stream on a given protocol.