interface.go 1.24 KB
Newer Older
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
1 2 3 4 5
package net

import (
	msg "github.com/jbenet/go-ipfs/net/message"
	mux "github.com/jbenet/go-ipfs/net/mux"
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
6
	srv "github.com/jbenet/go-ipfs/net/service"
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
	peer "github.com/jbenet/go-ipfs/peer"
)

// 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

29 30 31
	// GetPeerList returns the list of peers currently connected in this network.
	GetPeerList() []*peer.Peer

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
32
	// SendMessage sends given Message out
33
	SendMessage(msg.NetMessage) error
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
34 35 36 37

	// Close terminates all network operation
	Close() error
}
38 39

// Sender interface for network services.
40
type Sender srv.Sender
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
41 42 43

// Handler interface for network services.
type Handler srv.Handler
44 45 46

// Service interface for network resources.
type Service srv.Service