Skip to content
This repository was archived by the owner on Oct 23, 2022. It is now read-only.

remove unimplemented ipns functionalities from Ipfs #384

Merged
merged 6 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
fn main() {
prost_build::compile_protos(
&["src/ipns/ipns_pb.proto", "src/ipld/dag_pb.proto"],
&["src"],
)
.unwrap();
prost_build::compile_protos(&["src/ipld/dag_pb.proto"], &["src"]).unwrap();
}
36 changes: 0 additions & 36 deletions examples/ipfs_ipns_test.rs

This file was deleted.

File renamed without changes.
151 changes: 0 additions & 151 deletions src/ipns/entry.rs

This file was deleted.

31 changes: 3 additions & 28 deletions src/ipns/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
#![allow(dead_code)]
use crate::error::Error;
use crate::path::{IpfsPath, PathRoot};
use crate::repo::RepoTypes;
use crate::Ipfs;
use libp2p::PeerId;

mod dns;
mod entry;
mod ipns_pb {
include!(concat!(env!("OUT_DIR"), "/ipns_pb.rs"));
}
mod dnslink;

#[derive(Clone, Debug)]
pub struct Ipns<Types: RepoTypes> {
Expand All @@ -26,27 +20,8 @@ impl<Types: RepoTypes> Ipns<Types> {
let path = path.to_owned();
match path.root() {
PathRoot::Ipld(_) => Ok(path),
PathRoot::Ipns(peer_id) => match self.ipfs.repo.get_ipns(peer_id).await? {
Some(path) => Ok(path),
None => Err(anyhow::anyhow!("unimplemented")),
},
PathRoot::Dns(domain) => Ok(dns::resolve(domain).await?),
PathRoot::Ipns(_) => Err(anyhow::anyhow!("unimplemented")),
PathRoot::Dns(domain) => Ok(dnslink::resolve(domain).await?),
}
}

/// Publishes an ipld path.
pub async fn publish(&self, key: &PeerId, path: &IpfsPath) -> Result<IpfsPath, Error> {
let future = self.ipfs.repo.put_ipns(key, path);
let key = key.to_owned();
let mut path = path.to_owned();
future.await?;
path.set_root(PathRoot::Ipns(key));
Ok(path)
}

/// Cancel an ipns path.
pub async fn cancel(&self, key: &PeerId) -> Result<(), Error> {
self.ipfs.repo.remove_ipns(key).await?;
Ok(())
}
}
15 changes: 1 addition & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ impl<Types: IpfsTypes> Ipfs<Types> {
.await
}

/// Resolves a ipns path to an ipld path.
/// Resolves a ipns path to an ipld path; currently only supports dnslink resolution.
pub async fn resolve_ipns(&self, path: &IpfsPath, recursive: bool) -> Result<IpfsPath, Error> {
async move {
let ipns = self.ipns();
Expand All @@ -639,19 +639,6 @@ impl<Types: IpfsTypes> Ipfs<Types> {
.await
}

/// Publishes an ipld path.
pub async fn publish_ipns(&self, key: &PeerId, path: &IpfsPath) -> Result<IpfsPath, Error> {
self.ipns()
.publish(key, path)
.instrument(self.span.clone())
.await
}

/// Cancel an ipns path.
pub async fn cancel_ipns(&self, key: &PeerId) -> Result<(), Error> {
self.ipns().cancel(key).instrument(self.span.clone()).await
}

pub async fn connect(&self, target: MultiaddrWithPeerId) -> Result<(), Error> {
async move {
let (tx, rx) = oneshot_channel();
Expand Down