Documentation ¶
Index ¶
- Variables
- func NewTransport(ctx context.Context, l *zap.Logger, driver NativeDriver) func(h host.Host, u *tptu.Upgrader) (*proximityTransport, error)
- type Addr
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) LocalMultiaddr() ma.Multiaddr
- func (c *Conn) Read(payload []byte) (n int, err error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) RemoteMultiaddr() ma.Multiaddr
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) Write(payload []byte) (n int, err error)
- type Listener
- type NativeDriver
- type NoopNativeDriver
- func (d *NoopNativeDriver) CloseConnWithPeer(_ string)
- func (d *NoopNativeDriver) DefaultAddr() string
- func (d *NoopNativeDriver) DialPeer(_ string) bool
- func (d *NoopNativeDriver) ProtocolCode() int
- func (d *NoopNativeDriver) ProtocolName() string
- func (d *NoopNativeDriver) SendToPeer(_ string, _ []byte) bool
- func (d *NoopNativeDriver) Start(_ string)
- func (d *NoopNativeDriver) Stop()
- type ProximityTransport
- type RingBufferMap
Constants ¶
This section is empty.
Variables ¶
var TransportMap sync.Map
TransportMap prevents instantiating multiple Transport
Functions ¶
Types ¶
type Addr ¶
type Addr struct { Address string // contains filtered or unexported fields }
Addr represents a network end point address.
type Conn ¶
Conn is the equivalent of a net.Conn object. It is the result of calling the Dial or Listen functions in this package, with associated local and remote Multiaddrs.
func (*Conn) Close ¶
Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.
func (*Conn) LocalMultiaddr ¶
LocalMultiaddr returns the local Multiaddr associated with this connection.
func (*Conn) RemoteAddr ¶
RemoteAddr returns the remote network address.
func (*Conn) RemoteMultiaddr ¶
RemoteMultiaddr returns the remote Multiaddr associated with this connection.
func (*Conn) SetReadDeadline ¶
SetReadDeadline does nothing
func (*Conn) SetWriteDeadline ¶
SetWriteDeadline does nothing
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener is an interface closely resembling the net.Listener interface. The only real difference is that Accept() returns Conn's of the type in this package, and also exposes a Multiaddr method as opposed to a regular Addr method.
func (*Listener) Accept ¶
func (l *Listener) Accept() (tpt.CapableConn, error)
Accept waits for and returns the next connection to the listener. Returns a Multiaddr friendly Conn.
type NativeDriver ¶
type NativeDriver interface { // Start the native driver Start(localPID string) // Stop the native driver Stop() // Check if the native driver is connected to the remote peer DialPeer(remotePID string) bool // Send data to the remote peer SendToPeer(remotePID string, payload []byte) bool // Close the connection with the remote peer CloseConnWithPeer(remotePID string) // Return the multiaddress protocol code ProtocolCode() int // Return the multiaddress protocol name ProtocolName() string // Return the default multiaddress DefaultAddr() string }
type NoopNativeDriver ¶
type NoopNativeDriver struct {
// contains filtered or unexported fields
}
func NewNoopNativeDriver ¶
func NewNoopNativeDriver(protocolCode int, protocolName, defaultAddr string) *NoopNativeDriver
func (*NoopNativeDriver) CloseConnWithPeer ¶
func (d *NoopNativeDriver) CloseConnWithPeer(_ string)
func (*NoopNativeDriver) DefaultAddr ¶
func (d *NoopNativeDriver) DefaultAddr() string
func (*NoopNativeDriver) DialPeer ¶
func (d *NoopNativeDriver) DialPeer(_ string) bool
func (*NoopNativeDriver) ProtocolCode ¶
func (d *NoopNativeDriver) ProtocolCode() int
func (*NoopNativeDriver) ProtocolName ¶
func (d *NoopNativeDriver) ProtocolName() string
func (*NoopNativeDriver) SendToPeer ¶
func (d *NoopNativeDriver) SendToPeer(_ string, _ []byte) bool
func (*NoopNativeDriver) Start ¶
func (d *NoopNativeDriver) Start(_ string)
func (*NoopNativeDriver) Stop ¶
func (d *NoopNativeDriver) Stop()
type ProximityTransport ¶
type RingBufferMap ¶
RingBufferMap is a map of string:ringBuffer(aka circular buffer) The key is a peerID.
func NewRingBufferMap ¶
func NewRingBufferMap(logger *zap.Logger, size int) *RingBufferMap
NewRingBufferMap returns a new connMgr struct The size argument is the number of packets to save in cache.
func (*RingBufferMap) Add ¶
func (rbm *RingBufferMap) Add(peerID string, payload []byte)
Add adds the payload into a circular cache
func (*RingBufferMap) Flush ¶
func (rbm *RingBufferMap) Flush(peerID string) <-chan []byte
Flush puts the cache contents into a chan and clears it