From 3b69148977bcc3b5b3cb57882b75a407a381b00f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 7 Dec 2021 10:17:01 +0100 Subject: Pin all content that is posted Signed-off-by: Matthias Beyer --- src/client.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/client.rs b/src/client.rs index bb280a5..da8ad94 100644 --- a/src/client.rs +++ b/src/client.rs @@ -79,7 +79,13 @@ impl Client { } async fn post>(&self, s: S) -> Result { - self.ipfs.put_dag(s.into()).await.map_err(anyhow::Error::from) + let cid = self.ipfs.put_dag(s.into()).await?; + self.pin(&cid).await?; + Ok(cid) + } + + async fn pin(&self, cid: &cid::Cid) -> Result<()> { + self.ipfs.insert_pin(cid, false).await.map_err(anyhow::Error::from) } pub async fn get_node(&self, cid: Cid) -> Result { -- cgit v1.2.3