Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ListenerInfo ¶
type ListenerInfo struct { // Application protocol identifier. Protocol string // Node identity Identity peer.ID // Local protocol stream address. Address ma.Multiaddr // Local protocol stream listener. Closer io.Closer // Flag indicating whether we're still accepting incoming connections, or // whether this application listener has been shutdown. Running bool Registry *ListenerRegistry }
ListenerInfo holds information on a p2p listener.
func (*ListenerInfo) Close ¶
func (c *ListenerInfo) Close() error
Close closes the listener. Does not affect child streams
type ListenerRegistry ¶
type ListenerRegistry struct {
Listeners []*ListenerInfo
}
ListenerRegistry is a collection of local application protocol listeners.
func (*ListenerRegistry) Deregister ¶
func (c *ListenerRegistry) Deregister(proto string) error
Deregister removes p2p listener from this registry
func (*ListenerRegistry) Register ¶
func (c *ListenerRegistry) Register(listenerInfo *ListenerInfo)
Register registers listenerInfo2 in this registry
type P2P ¶
type P2P struct { Listeners ListenerRegistry Streams StreamRegistry // contains filtered or unexported fields }
P2P structure holds information on currently running streams/listeners
func (*P2P) CheckProtoExists ¶
CheckProtoExists checks whether a protocol handler is registered to mux handler
func (*P2P) Dial ¶
func (p2p *P2P) Dial(ctx context.Context, addr ma.Multiaddr, peer peer.ID, proto string, bindAddr ma.Multiaddr) (*ListenerInfo, error)
Dial creates new P2P stream to a remote listener
func (*P2P) NewListener ¶
func (p2p *P2P) NewListener(ctx context.Context, proto string, addr ma.Multiaddr) (*ListenerInfo, error)
NewListener creates new p2p listener
type P2PListener ¶
type P2PListener struct {
// contains filtered or unexported fields
}
P2PListener holds information on a listener
func (*P2PListener) Accept ¶
func (il *P2PListener) Accept() (net.Stream, error)
Accept waits for a connection from the listener
func (*P2PListener) Close ¶
func (il *P2PListener) Close() error
Close closes the listener and removes stream handler
type StreamInfo ¶
type StreamInfo struct { HandlerID uint64 Protocol string LocalPeer peer.ID LocalAddr ma.Multiaddr RemotePeer peer.ID RemoteAddr ma.Multiaddr Local manet.Conn Remote net.Stream Registry *StreamRegistry }
StreamInfo holds information on active incoming and outgoing p2p streams.
func (*StreamInfo) Close ¶
func (s *StreamInfo) Close() error
Close closes stream endpoints and deregisters it
func (*StreamInfo) Reset ¶ added in v0.4.11
func (s *StreamInfo) Reset() error
Reset closes stream endpoints and deregisters it
type StreamRegistry ¶
type StreamRegistry struct { Streams []*StreamInfo // contains filtered or unexported fields }
StreamRegistry is a collection of active incoming and outgoing protocol app streams.
func (*StreamRegistry) Deregister ¶
func (c *StreamRegistry) Deregister(handlerID uint64)
Deregister deregisters stream from the registry
func (*StreamRegistry) Register ¶
func (c *StreamRegistry) Register(streamInfo *StreamInfo)
Register registers a stream to the registry