Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
interface-go-dms3-core
Commits
a48b2a80
Commit
a48b2a80
authored
Sep 17, 2018
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coreapi swarm: rewire connect/disconnect
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
59f549fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
swarm.go
swarm.go
+15
-8
No files found.
swarm.go
View file @
a48b2a80
...
...
@@ -2,14 +2,22 @@ package iface
import
(
"context"
"errors"
"time"
ma
"gx/ipfs/QmYmsdtJ3HsodkePE3eU3TsCaP2YvPZJ4LoXnNkDE5Tpt7/go-multiaddr"
peer
"gx/ipfs/QmbNepETomvmXfz1X5pHNFD2QuPqnqi47dTd94QJWSorQ3/go-libp2p-peer"
"gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol"
"gx/ipfs/QmbNepETomvmXfz1X5pHNFD2QuPqnqi47dTd94QJWSorQ3/go-libp2p-peer"
pstore
"gx/ipfs/QmfAQMFpgDU2U4BXG64qVr8HSiictfWvkSBz7Y2oDj65st/go-libp2p-peerstore"
)
// PeerInfo contains information about a peer
type
PeerInfo
interface
{
var
(
ErrNotConnected
=
errors
.
New
(
"not connected"
)
ErrConnNotFound
=
errors
.
New
(
"conn not found"
)
)
// ConnectionInfo contains information about a peer
type
ConnectionInfo
interface
{
// ID returns PeerID
ID
()
peer
.
ID
...
...
@@ -20,18 +28,17 @@ type PeerInfo interface {
Latency
(
context
.
Context
)
(
time
.
Duration
,
error
)
// Streams returns list of streams established with the peer
// TODO: should this return multicodecs?
Streams
(
context
.
Context
)
([]
string
,
error
)
Streams
(
context
.
Context
)
([]
protocol
.
ID
,
error
)
}
// SwarmAPI specifies the interface to libp2p swarm
type
SwarmAPI
interface
{
// Connect to a given
address
Connect
(
context
.
Context
,
ma
.
Multiaddr
)
error
// Connect to a given
peer
Connect
(
context
.
Context
,
pstore
.
PeerInfo
)
error
// Disconnect from a given address
Disconnect
(
context
.
Context
,
ma
.
Multiaddr
)
error
// Peers returns the list of peers we are connected to
Peers
(
context
.
Context
)
([]
Peer
Info
,
error
)
Peers
(
context
.
Context
)
([]
Connection
Info
,
error
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment