reformatting repo/mod.rs
@@ -131,15 +131,13 @@ impl<TRepoTypes: RepoTypes> Repo<TRepoTypes> {
/// Puts a block into the block store.
pub async fn put_block(&self, block: Block) -> Result<Cid, Error> {
let cid = self.block_store.put(block.clone()).await?;
- self
- .subscriptions
+ self.subscriptions
.lock()
.await
.finish_subscription(&cid, block);
// sending only fails if no one is listening anymore
// and that is okay with us.
- self
- .events
+ self.events
.clone()
.send(RepoEvent::ProvideBlock(cid.clone()))
.await
@@ -159,8 +157,7 @@ impl<TRepoTypes: RepoTypes> Repo<TRepoTypes> {
.create_subscription(cid.clone());
// sending only fails if no one is listening anymore
// and that is okay with us.
- self
- .events
+ self.events
.clone()
.send(RepoEvent::WantBlock(cid.clone()))
.await
@@ -172,8 +169,7 @@ impl<TRepoTypes: RepoTypes> Repo<TRepoTypes> {
/// Remove block from the block store.
pub async fn remove_block(&self, cid: &Cid) -> Result<(), Error> {
// sending only fails if the background task has exited
- self
- .events
+ self.events
.clone()
.send(RepoEvent::UnprovideBlock(cid.to_owned()))
.await
@@ -203,8 +199,7 @@ impl<TRepoTypes: RepoTypes> Repo<TRepoTypes> {
pub async fn put_ipns(&self, ipns: &PeerId, path: &IpfsPath) -> Result<(), Error> {
let string = path.to_string();
let value = string.as_bytes();
- self
- .data_store
+ self.data_store
.put(Column::Ipns, ipns.as_bytes(), value)
.await
}
@@ -215,15 +210,13 @@ impl<TRepoTypes: RepoTypes> Repo<TRepoTypes> {
}
pub async fn pin_block(&self, ipns: &PeerId, cid: &Cid) -> Result<(), Error> {
- self
- .data_store
+ self.data_store
.put(Column::Ipns, &cid.to_bytes(), &vec![1])
.await
}
pub async fn unpin_block(&self, ipns: &PeerId, cid: &Cid) -> Result<(), Error> {
- self
- .data_store
+ self.data_store
.put(Column::Ipns, &cid.to_bytes(), &vec![0])
.await
}
