Documentation ¶
Index ¶
- type Config
- type Network
- func (net *Network) Addrs() []multiaddr.Multiaddr
- func (net *Network) Close() error
- func (net *Network) Connect(ctx context.Context, peer pstore.PeerInfo) error
- func (net *Network) Context() context.Context
- func (net *Network) HandlePeerFound(peer pstore.PeerInfo)
- func (net *Network) InitMDNS() error
- func (net *Network) WaitForBootstrap()
- type RPC
- type Router
- type Stream
- type StreamHandler
- type StreamMgr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { //RendezvousString is a unique string to identify group of nodes RendezvousString string //ListenHost is the host IP address network listens on. //Use 0.0.0.0 for listening on all interfaces ListenHost string //ListenPort is the host port to listens on. ListenPort int //BootstrapPeer is the multiaddress of bootstrap peer if there is any BootstrapPeers []multiaddr.Multiaddr //File to save and read key file KeyFile string //Enable/Disable circuit relay, enable if you are willing to volunteer as a relay point EnableRelay bool }
Config for the network
type Network ¶
type Network struct { //ID of this Host UUID string //Stream manager StreamMgr *StreamMgr //RPC object of network RPC *RPC //Router object of network Router *Router //libp2p host handle. We dont need this mostly Host host.Host // contains filtered or unexported fields }
Network represents libp2p network layer.
func NewNetwork ¶
NewNetwork creates a network handle
func (*Network) HandlePeerFound ¶
HandlePeerFound is the Notifee interface for mdns discovery. It can be also called to update the peer info found via other ways
func (*Network) WaitForBootstrap ¶
func (net *Network) WaitForBootstrap()
WaitForBootstrap blocks untill local peer is bootstrapped
type RPC ¶
type RPC struct {
// contains filtered or unexported fields
}
RPC represents a RPC object of a host. It represents both server and client
func (*RPC) Call ¶
func (rpc *RPC) Call(ctx context.Context, dest peer.ID, service, method string, args, reply interface{}) error
Call performs an RPC call to a registered Server service and blocks until completed.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router handles service advertising and discovery.
type Stream ¶
type Stream interface { io.ReadWriter // Close closes the stream for writing. Reading will still work (that // is, the remote side can still write). io.Closer // Reset closes both ends of the stream. Use this to tell the remote // side to hang up and go away. Reset() error }
Stream represents a bidirectional channel between two agents
type StreamHandler ¶
type StreamHandler func(Stream)
StreamHandler is the type of function used to listen for streams opened by the remote side.
type StreamMgr ¶
type StreamMgr struct {
// contains filtered or unexported fields
}
StreamMgr handles connections of network
func (*StreamMgr) RemoveHandler ¶
RemoveHandler removes the protocol handler
func (*StreamMgr) SetHandler ¶
func (mgr *StreamMgr) SetHandler(pid protocol.ID, handler StreamHandler)
SetHandler sets the protocol handler on host.