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

Commit 251a744

Browse files
bors[bot]ljedrz
andauthored
Merge #384
384: remove unimplemented ipns functionalities from Ipfs r=ljedrz a=ljedrz Remove ipns insertion and cancellation features from `ipfs::Ipfs` (they are not implemented). Cc #356 Co-authored-by: ljedrz <[email protected]>
2 parents ffc65c8 + df8a12e commit 251a744

File tree

6 files changed

+5
-234
lines changed

6 files changed

+5
-234
lines changed

build.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
fn main() {
2-
prost_build::compile_protos(
3-
&["src/ipns/ipns_pb.proto", "src/ipld/dag_pb.proto"],
4-
&["src"],
5-
)
6-
.unwrap();
2+
prost_build::compile_protos(&["src/ipld/dag_pb.proto"], &["src"]).unwrap();
73
}

examples/ipfs_ipns_test.rs

-36
This file was deleted.
File renamed without changes.

src/ipns/entry.rs

-151
This file was deleted.

src/ipns/mod.rs

+3-28
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
#![allow(dead_code)]
21
use crate::error::Error;
32
use crate::path::{IpfsPath, PathRoot};
43
use crate::repo::RepoTypes;
54
use crate::Ipfs;
6-
use libp2p::PeerId;
75

8-
mod dns;
9-
mod entry;
10-
mod ipns_pb {
11-
include!(concat!(env!("OUT_DIR"), "/ipns_pb.rs"));
12-
}
6+
mod dnslink;
137

148
#[derive(Clone, Debug)]
159
pub struct Ipns<Types: RepoTypes> {
@@ -26,27 +20,8 @@ impl<Types: RepoTypes> Ipns<Types> {
2620
let path = path.to_owned();
2721
match path.root() {
2822
PathRoot::Ipld(_) => Ok(path),
29-
PathRoot::Ipns(peer_id) => match self.ipfs.repo.get_ipns(peer_id).await? {
30-
Some(path) => Ok(path),
31-
None => Err(anyhow::anyhow!("unimplemented")),
32-
},
33-
PathRoot::Dns(domain) => Ok(dns::resolve(domain).await?),
23+
PathRoot::Ipns(_) => Err(anyhow::anyhow!("unimplemented")),
24+
PathRoot::Dns(domain) => Ok(dnslink::resolve(domain).await?),
3425
}
3526
}
36-
37-
/// Publishes an ipld path.
38-
pub async fn publish(&self, key: &PeerId, path: &IpfsPath) -> Result<IpfsPath, Error> {
39-
let future = self.ipfs.repo.put_ipns(key, path);
40-
let key = key.to_owned();
41-
let mut path = path.to_owned();
42-
future.await?;
43-
path.set_root(PathRoot::Ipns(key));
44-
Ok(path)
45-
}
46-
47-
/// Cancel an ipns path.
48-
pub async fn cancel(&self, key: &PeerId) -> Result<(), Error> {
49-
self.ipfs.repo.remove_ipns(key).await?;
50-
Ok(())
51-
}
5227
}

src/lib.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ impl<Types: IpfsTypes> Ipfs<Types> {
615615
.await
616616
}
617617

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

642-
/// Publishes an ipld path.
643-
pub async fn publish_ipns(&self, key: &PeerId, path: &IpfsPath) -> Result<IpfsPath, Error> {
644-
self.ipns()
645-
.publish(key, path)
646-
.instrument(self.span.clone())
647-
.await
648-
}
649-
650-
/// Cancel an ipns path.
651-
pub async fn cancel_ipns(&self, key: &PeerId) -> Result<(), Error> {
652-
self.ipns().cancel(key).instrument(self.span.clone()).await
653-
}
654-
655642
pub async fn connect(&self, target: MultiaddrWithPeerId) -> Result<(), Error> {
656643
async move {
657644
let (tx, rx) = oneshot_channel();

0 commit comments

Comments
 (0)