@cryptotaxi247 / kubo / commits / 8404b8263

coreapi: swarm interface

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@bc2ae0a441ed2da875bf2d815766e90b2c2a4d9f This commit was moved from ipfs/boxo@398a8ffdf544dac64be994ce4a34ef3013d9d584

Łukasz Magiera committed Mar 10, 2018 at 18:54 UTC 8404b8263de39467bda064cdce59293db5914a40
1 file changed +37
core/coreiface/swarm.go new
+37
@@ -0,0 +1,37 @@
1 +package iface
2 +
3 +import (
4 + "time"
5 +
6 + "context"
7 + ma "gx/ipfs/QmWWQ2Txc2c6tqjsBpzg5Ar652cHPGNsQQp2SejkNmkUMb/go-multiaddr"
8 + peer "gx/ipfs/QmZoWKhxUmZ2seW4BzX6fJkNR8hh9PsGModr7q171yq2SS/go-libp2p-peer"
9 +)
10 +
11 +// PeerInfo contains information about a peer
12 +type PeerInfo interface {
13 + // ID returns PeerID
14 + ID() peer.ID
15 +
16 + // Address returns the multiaddress via which we are connected with the peer
17 + Address() ma.Multiaddr
18 +
19 + // Latency returns last known round trip time to the peer
20 + Latency() time.Duration
21 +
22 + // Streams returns list of streams established with the peer
23 + // TODO: should this return multicodecs?
24 + Streams() []string
25 +}
26 +
27 +// SwarmAPI specifies the interface to libp2p swarm
28 +type SwarmAPI interface {
29 + // Connect to a given address
30 + Connect(context.Context, ma.Multiaddr) error
31 +
32 + // Disconnect from a given address
33 + Disconnect(context.Context, ma.Multiaddr) error
34 +
35 + // Peers returns the list of peers we are connected to
36 + Peers(context.Context) ([]PeerInfo, error)
37 +}