Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
Adding transport.QListener
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorropo committed Feb 29, 2020
1 parent 2d4fee4 commit 52e1ead
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions transport/transport.go
Expand Up @@ -124,6 +124,9 @@ type Transport interface {
// Dial dials a remote peer. It should try to reuse local listener
// addresses if possible but it may choose not to.
Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (CapableConn, error)

// Listen listens on the passed multiaddr.
Listen(laddr ma.Multiaddr) (Listener, error)
}

type QTransport interface {
Expand All @@ -133,6 +136,9 @@ type QTransport interface {
// addresses if possible but it may choose not to.
Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (QCapableConn, error)

// Listen listens on the passed multiaddr.
Listen(laddr ma.Multiaddr) (QListener, error)

// Score returns the Quality we can expect from the connection to this peer.
// That must be deterministic and fast.
Score(raddr ma.Multiaddr, p peer.ID) (Score, error)
Expand All @@ -147,9 +153,6 @@ type BaseTransport interface {
// out addresses that we can't dial.
CanDial(addr ma.Multiaddr) bool

// Listen listens on the passed multiaddr.
Listen(laddr ma.Multiaddr) (Listener, error)

// Protocol returns the set of protocols handled by this transport.
//
// See the Network interface for an explanation of how this is used.
Expand All @@ -167,7 +170,20 @@ type BaseTransport interface {
// package, and also exposes a Multiaddr method as opposed to a regular Addr
// method
type Listener interface {
BaseListener

Accept() (CapableConn, error)
}

// QListener is like listener but produce QCapableConn instead of CapableConn.
type QListener interface {
BaseListener

Accept() (QCapableConn, error)
}

// BaseListener is used to build `Lister` and `QListener`
type BaseListener interface {
Close() error
Addr() net.Addr
Multiaddr() ma.Multiaddr
Expand Down

0 comments on commit 52e1ead

Please sign in to comment.