This repository has been archived by the owner on Jun 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package iface | ||
|
||
import ( | ||
"time" | ||
|
||
"context" | ||
ma "gx/ipfs/QmWWQ2Txc2c6tqjsBpzg5Ar652cHPGNsQQp2SejkNmkUMb/go-multiaddr" | ||
peer "gx/ipfs/QmZoWKhxUmZ2seW4BzX6fJkNR8hh9PsGModr7q171yq2SS/go-libp2p-peer" | ||
) | ||
|
||
// PeerInfo contains information about a peer | ||
type PeerInfo interface { | ||
// ID returns PeerID | ||
ID() peer.ID | ||
|
||
// Address returns the multiaddress via which we are connected with the peer | ||
Address() ma.Multiaddr | ||
|
||
// Latency returns last known round trip time to the peer | ||
Latency() time.Duration | ||
|
||
// Streams returns list of streams established with the peer | ||
// TODO: should this return multicodecs? | ||
Streams() []string | ||
} | ||
|
||
// SwarmAPI specifies the interface to libp2p swarm | ||
type SwarmAPI interface { | ||
// Connect to a given address | ||
Connect(context.Context, ma.Multiaddr) 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) ([]PeerInfo, error) | ||
} |