1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-11 15:15:58 +08:00
Files
kubo/net/interface.go
Juan Batiz-Benet 9849794b07 Move Sender interface to network pkg
@perfmode sender is exactly what we need to pass in to dht/bitswap.
2014-09-22 04:05:16 -07:00

46 lines
1.4 KiB
Go

package net
import (
msg "github.com/jbenet/go-ipfs/net/message"
mux "github.com/jbenet/go-ipfs/net/mux"
peer "github.com/jbenet/go-ipfs/peer"
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
)
// Network is the interface IPFS uses for connecting to the world.
type Network interface {
// Listen handles incoming connections on given Multiaddr.
// Listen(*ma.Muliaddr) error
// TODO: for now, only listen on addrs in local peer when initializing.
// DialPeer attempts to establish a connection to a given peer
DialPeer(*peer.Peer) error
// ClosePeer connection to peer
ClosePeer(*peer.Peer) error
// IsConnected returns whether a connection to given peer exists.
IsConnected(*peer.Peer) (bool, error)
// GetProtocols returns the protocols registered in the network.
GetProtocols() *mux.ProtocolMap
// SendMessage sends given Message out
SendMessage(msg.NetMessage) error
// Close terminates all network operation
Close() error
}
// Sender interface for network services.
type Sender interface {
// SendMessage sends out a given message, without expecting a response.
SendMessage(ctx context.Context, m msg.NetMessage) error
// SendRequest sends out a given message, and awaits a response.
// Set Deadlines or cancellations in the context.Context you pass in.
SendRequest(ctx context.Context, m msg.NetMessage) (msg.NetMessage, error)
}