summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-04-28 19:25:21 +0200
committerMatthias Beyer <mail@beyermatthias.de>2020-04-28 20:26:27 +0200
commit605009d6219e7272baa2cc100a949d54852cb52d (patch)
treef414cefae3066ea85a83cfd52442c655bd4ebc58 /src
parent963cac60bea36c658aa5f5a267aaed551690a64d (diff)
Add client function to publish hash with key
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src')
-rw-r--r--src/repository/client.rs14
-rw-r--r--src/repository/repository.rs4
2 files changed, 18 insertions, 0 deletions
diff --git a/src/repository/client.rs b/src/repository/client.rs
index c21df0b..3cd023d 100644
--- a/src/repository/client.rs
+++ b/src/repository/client.rs
@@ -59,6 +59,16 @@ impl ClientFassade {
.map(|res| IPFSHash::from(res.hash))
.map_err(Into::into)
}
+
+ async fn publish(&self, key: &str, hash: &str) -> Result<IPNSHash, Error> {
+ debug!("Publish: {:?} -> {:?}", key, hash);
+ self.0
+ .clone()
+ .name_publish(hash, false, None, None, Some(key))
+ .await
+ .map(|res| IPNSHash::from(res.value))
+ .map_err(Into::into)
+ }
}
/// Client wrapper for working with types directly on the client
@@ -101,4 +111,8 @@ impl TypedClientFassade {
client.put(data.into_bytes()).await
}
+ pub async fn publish(&self, key: &str, hash: &str) -> Result<IPNSHash, Error> {
+ self.0.publish(key, hash).await
+ }
+
}
diff --git a/src/repository/repository.rs b/src/repository/repository.rs
index c162e65..35c83a2 100644
--- a/src/repository/repository.rs
+++ b/src/repository/repository.rs
@@ -66,5 +66,9 @@ impl Repository {
self.0.put(c.as_ref()).await
}
+ pub async fn publish(&self, key: &str, hash: &str) -> Result<IPNSHash, Error> {
+ self.0.publish(key, hash).await
+ }
+
}