Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BitSwapNetwork ¶
type BitSwapNetwork interface { // SendMessage sends a BitSwap message to a peer. SendMessage( context.Context, peer.ID, bsmsg.BitSwapMessage) error // Start registers the Reciver and starts handling new messages, connectivity events, etc. Start(...Receiver) // Stop stops the network service. Stop() Connect(context.Context, peer.AddrInfo) error DisconnectFrom(context.Context, peer.ID) error NewMessageSender(context.Context, peer.ID, *MessageSenderOpts) (MessageSender, error) Stats() Stats Self() peer.ID Pinger PeerTagger }
BitSwapNetwork provides network connectivity for BitSwap sessions.
func New ¶ added in v0.29.0
func New(pstore peerstore.Peerstore, bitswap BitSwapNetwork, http BitSwapNetwork) BitSwapNetwork
New returns a BitSwapNetwork supported by underlying IPFS host.
type ConnectEventManager ¶ added in v0.29.0
type ConnectEventManager struct {
// contains filtered or unexported fields
}
func NewConnectEventManager ¶ added in v0.29.0
func NewConnectEventManager(connListeners ...ConnectionListener) *ConnectEventManager
func (*ConnectEventManager) Connected ¶ added in v0.29.0
func (c *ConnectEventManager) Connected(p peer.ID)
Called whenever we receive a new connection. May be called many times.
func (*ConnectEventManager) Disconnected ¶ added in v0.29.0
func (c *ConnectEventManager) Disconnected(p peer.ID)
Called when we drop the final connection to a peer.
func (*ConnectEventManager) MarkUnresponsive ¶ added in v0.29.0
func (c *ConnectEventManager) MarkUnresponsive(p peer.ID)
Called whenever a peer is unresponsive.
func (*ConnectEventManager) OnMessage ¶ added in v0.29.0
func (c *ConnectEventManager) OnMessage(p peer.ID)
Called whenever we receive a message from a peer.
- When we're connected to the peer, this will mark the peer as responsive (from unresponsive). - When not connected, we ignore this call. Unfortunately, a peer may disconnect before we process
the "on message" event, so we can't treat this as evidence of a connection.
func (*ConnectEventManager) Start ¶ added in v0.29.0
func (c *ConnectEventManager) Start()
func (*ConnectEventManager) Stop ¶ added in v0.29.0
func (c *ConnectEventManager) Stop()
type ConnectionListener ¶
type MessageSender ¶
type MessageSender interface { SendMsg(context.Context, bsmsg.BitSwapMessage) error Reset() error // Indicates whether the remote peer supports HAVE / DONT_HAVE messages SupportsHave() bool }
MessageSender is an interface for sending a series of messages over the bitswap network
type MessageSenderOpts ¶
type ParsedURL ¶ added in v0.29.0
ParsedURL contains the result of parsing an "http" transport multiaddress. SNI is set when the multiaddress specifies an SNI value.
func ExtractHTTPAddress ¶ added in v0.29.0
ExtractHTTPAddress extracts the HTTP schema+host+port from a multiaddress and returns a *url.URL and an SNI string if present.
func ExtractURLsFromPeer ¶ added in v0.29.0
ExtractURLsFromPeer extracts all HTTP schema+host+port addresses as ParsedURL from a peer.AddrInfo object.
type PeerTagger ¶ added in v0.29.0
type PeerTagger interface { TagPeer(peer.ID, string, int) UntagPeer(peer.ID, string) Protect(peer.ID, string) Unprotect(peer.ID, string) bool }
PeerTagger is an interface for tagging peers with metadata
type Pinger ¶
type Pinger interface { // Ping a peer Ping(context.Context, peer.ID) ping.Result // Get the average latency of all pings Latency(peer.ID) time.Duration }
Pinger is an interface to ping a peer and get the average latency of all pings
type Receiver ¶
type Receiver interface { ReceiveMessage( ctx context.Context, sender peer.ID, incoming bsmsg.BitSwapMessage) ReceiveError(error) // Connected/Disconnected warns bitswap about peer connections. PeerConnected(peer.ID) PeerDisconnected(peer.ID) }
Receiver is an interface that can receive messages from the BitSwapNetwork.