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
that pushes changes to a Peers listening addresses and protocols as they update in realtime./ipfs/id
that pushes delta
(partial) Peer Records that contain changes since an initial /ipfs/id
Peer Record exchangelet 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"),
]),
...
)
/// 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.
link |
Stars: 0 |
Last commit: 38 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics