Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Listener ¶
type Listener interface {
Accept() (net.Stream, error)
Close() error
}
Listener wraps stream handler into a listener
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.
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
type P2P ¶
type P2P struct {
Listeners ListenerRegistry
Streams StreamRegistry
// contains filtered or unexported fields
}
P2P structure holds information on currently running streams/listeners
func NewP2P ¶
func NewP2P(identity peer.ID, peerHost p2phost.Host, peerstore pstore.Peerstore) *P2P
NewP2P creates new P2P struct
func (*P2P) CheckProtoExists ¶
func (p2p *P2P) CheckProtoExists(proto string) bool
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
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.
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