A core set of protocols used for
Identify
ing peers within libp2p
Identify consists of a set of protocols used to help identify remote peers within the libp2p ecosystem. The protocols included within Identify are...
- /ipfs/id
- This protocol exchanges Signed Peer Records used for confirming a remote Peer is who they claim to be, the addresses they're listening on and the protocols they speak.
- /ipfs/id/push
- An extension of
/ipfs/id
that pushes changes to a Peers listening addresses and protocols as they update in realtime.
- An extension of
- /ipfs/id/delta
- An extension of
/ipfs/id
that pushesdelta
(partial) Peer Records that contain changes since an initial/ipfs/id
Peer Record exchange
- An extension of
- /ipfs/ping
- A ping protocol that allows for quick and easy pings to libp2p Peers for measuring latency, testing liveness/connectivity, etc.
- This package is embedded into swift-libp2p . There's no need to include this package as a dependency in your swift-libp2p project.
- This package is embedded into swift-libp2p . There's no need to include this package as a dependency in your swift-libp2p project. Include the following dependency in your Package.swift file
let package = Package(
...
dependencies: [
...
.package(url: "https://github.com/swift-libp2p/swift-libp2p-identify.git", .upToNextMajor(from: "0.0.1"))
],
...
.target(
...
dependencies: [
...
.product(name: "LibP2PIdentify", package: "swift-libp2p-identify"),
]),
...
)
- This package is embedded into swift-libp2p . There's no need to include this package as a dependency in your swift-libp2p project.
/// Tell swift-libp2p to use Identify (the standard swift-libp2p implementation does this automatically)
app.identityManager.use(.default)
/// Manually ping a peer
app.identify.ping(peer: PeerID).map {
print("Latency: \($0)")
}
/// Manually ping a multiaddr
app.identify.ping(addr: Multiaddr).map {
print("Latency: \($0)")
}
/// Attempts to Ping a Peer, returns the time it took to receive a response.
public func ping(peer:PeerID) -> EventLoopFuture<TimeAmount>
/// Attempts to Ping a Multiaddr, returns the time it took to receive a response.
public func ping(addr:Multiaddr) -> EventLoopFuture<TimeAmount>
Contributions are welcomed! This code is very much a proof of concept. I can guarantee you there's a better / safer way to accomplish the same results. Any suggestions, improvements, or even just critques, are welcome!
Let's make this code better together! 🤝
MIT © 2022 Breth Inc.