diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-12-07 10:17:01 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-12-08 18:44:58 +0100 |
commit | 3b69148977bcc3b5b3cb57882b75a407a381b00f (patch) | |
tree | 692547f221e2b4a669fb0a7e04f74126c024a935 | |
parent | 7e94eaca8e0b11b0d982a480854177503c153a54 (diff) |
Pin all content that is posted
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | src/client.rs | 8 |
1 files changed, 7 insertions, 1 deletions
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<S: Into<ipfs::Ipld>>(&self, s: S) -> Result<Cid> { - 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<Node> { |