Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Commit

Permalink
remove dependency on interface-conn
Browse files Browse the repository at this point in the history
for transport refactor: libp2p/go-libp2p#297
  • Loading branch information
Stebalien committed Mar 9, 2018
1 parent 6bd1c6c commit 0fc4a59
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
35 changes: 33 additions & 2 deletions interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io"

"github.com/jbenet/goprocess"
iconn "github.com/libp2p/go-libp2p-interface-conn"
ic "github.com/libp2p/go-libp2p-crypto"
peer "github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore"
protocol "github.com/libp2p/go-libp2p-protocol"
Expand Down Expand Up @@ -37,12 +37,43 @@ type Stream interface {
// streams opened by the remote side.
type StreamHandler func(Stream)

// ConnSecurity is the interface that one can mix into a connection interface to
// give it the security methods.
type ConnSecurity interface {
// LocalPeer returns our peer ID
LocalPeer() peer.ID

// LocalPrivateKey returns our private key
LocalPrivateKey() ic.PrivKey

// RemotePeer returns the peer ID of the remote peer.
RemotePeer() peer.ID

// RemotePublicKey returns the public key of the remote peer.
RemotePublicKey() ic.PubKey
}

// ConnMultiaddrs is an interface mixin for connection types that provide multiaddr
// addresses for the endpoints.
type ConnMultiaddrs interface {
// LocalMultiaddr returns the local Multiaddr associated
// with this connection
LocalMultiaddr() ma.Multiaddr

// RemoteMultiaddr returns the remote Multiaddr associated
// with this connection
RemoteMultiaddr() ma.Multiaddr
}

// Conn is a connection to a remote peer. It multiplexes streams.
// Usually there is no need to use a Conn directly, but it may
// be useful to get information about the peer on the other side:
// stream.Conn().RemotePeer()
type Conn interface {
iconn.PeerConn
io.Closer

ConnSecurity
ConnMultiaddrs

// NewStream constructs a new Stream over this conn.
NewStream() (Stream, error)
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
"name": "go-libp2p-peerstore",
"version": "1.4.15"
},
{
"author": "whyrusleeping",
"hash": "QmToCvh5eJtoDheMggre7b2zeFCJ6tAyB82YVs457cqoUE",
"name": "go-libp2p-interface-conn",
"version": "0.4.12"
},
{
"author": "whyrusleeping",
"hash": "QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP",
Expand All @@ -48,6 +42,12 @@
"hash": "QmY9JXR3FupnYAYJWK9aMr9bCpqWKcToQ1tz8DVGTrHpHw",
"name": "go-stream-muxer",
"version": "3.0.0"
},
{
"author": "whyrusleeping",
"hash": "QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo",
"name": "go-libp2p-crypto",
"version": "1.5.0"
}
],
"gxVersion": "0.9.1",
Expand Down

0 comments on commit 0fc4a59

Please sign in to comment.