summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-12-10 17:56:41 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-12-10 17:56:41 +0100
commit20f376f70c107e686af11d6f09284c4fafc48d1a (patch)
treef830fece51db9c3bb78435577eeda5a9a1cc8ee0
parente04c9d592567292f1701ff37e17ccc9181e96dc6 (diff)
Add Client::own_id() for getting own PeerId
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--lib/src/client.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/src/client.rs b/lib/src/client.rs
index da8ad94..4d4a971 100644
--- a/lib/src/client.rs
+++ b/lib/src/client.rs
@@ -33,6 +33,14 @@ impl Client {
Ok(())
}
+ pub async fn own_id(&self) -> Result<ipfs::PeerId> {
+ self.ipfs
+ .identity()
+ .await
+ .map(|id| id.0.into_peer_id())
+ .map_err(anyhow::Error::from)
+ }
+
pub async fn connect(&self, peer: ipfs::MultiaddrWithPeerId) -> Result<()> {
self.ipfs.connect(peer).await
}