From fd47924ec25359c0e383874cc4cbddaa1d155c29 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 30 Apr 2020 10:43:38 +0200 Subject: Client: Add resolve() function for translating IPNS hash to IPFS hash Signed-off-by: Matthias Beyer --- src/repository/client.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/repository/client.rs b/src/repository/client.rs index 98de84e..59542c8 100644 --- a/src/repository/client.rs +++ b/src/repository/client.rs @@ -69,6 +69,15 @@ impl ClientFassade { .map(|res| IPNSHash::from(res.value)) .map_err(Into::into) } + + pub async fn resolve(&self, ipns: IPNSHash) -> Result { + self.0 + .clone() + .name_resolve(Some(&ipns), true, false) + .await + .map(|res| IPFSHash::from(res.path)) + .map_err(Into::into) + } } /// Client wrapper for working with types directly on the client -- cgit v1.2.3