From b5662a5cb42965efdf7181db027c2876773b6cd5 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Wed, 21 Apr 2021 22:30:32 +0200 Subject: [PATCH] refactor: remove proquint.go See discussion in: https://github.com/ipfs/go-namesys/pull/13#pullrequestreview-641398404 This commit was moved from ipfs/go-namesys@aa54bc9e2df08848ace68fcb1914eb850ee4fb8a --- namesys/README.md | 4 ++-- namesys/namesys.go | 16 +++++----------- namesys/proquint.go | 34 ---------------------------------- 3 files changed, 7 insertions(+), 47 deletions(-) delete mode 100644 namesys/proquint.go diff --git a/namesys/README.md b/namesys/README.md index 5c17728da..78060ca03 100644 --- a/namesys/README.md +++ b/namesys/README.md @@ -10,9 +10,9 @@ Package namesys defines `Resolver` and `Publisher` interfaces for IPNS paths, that is, paths in the form of `/ipns/`. A "resolved" IPNS path becomes an `/ipfs/` path. -Traditionally, these paths would be in the form of `/ipns/peer_id`, which references an IPNS record in a distributed `ValueStore` (usually the IPFS DHT). +Traditionally, these paths would be in the form of `/ipns/{libp2p-key}`, which references an IPNS record in a distributed `ValueStore` (usually the IPFS DHT). -Additionally, the /ipns/ namespace can also be used with domain names that use DNSLink (/ipns/my.domain.example, see https://dnslink.io) and proquint strings. +Additionally, the `/ipns/` namespace can also be used with domain names that use DNSLink (`/ipns/en.wikipedia-on-ipfs.org`, see https://docs.ipfs.io/concepts/dnslink/). The package provides implementations for all three resolvers. diff --git a/namesys/namesys.go b/namesys/namesys.go index b28c13309..f1c1d22c2 100644 --- a/namesys/namesys.go +++ b/namesys/namesys.go @@ -8,7 +8,6 @@ // // Additionally, the /ipns/ namespace can also be used with domain names that // use DNSLink (/ipns/, https://docs.ipfs.io/concepts/dnslink/) -// and proquint strings. // // The package provides implementations for all three resolvers. package namesys @@ -38,15 +37,14 @@ import ( // Uses several Resolvers: // (a) IPFS routing naming: SFS-like PKI names. // (b) dns domains: resolves using links in DNS TXT records -// (c) proquints: interprets string as the raw byte data. // // It can only publish to: (a) IPFS routing naming. // type mpns struct { ds ds.Datastore - dnsResolver, proquintResolver, ipnsResolver resolver - ipnsPublisher Publisher + dnsResolver, ipnsResolver resolver + ipnsPublisher Publisher staticMap map[string]path.Path cache *lru.Cache @@ -125,7 +123,6 @@ func NewNameSystem(r routing.ValueStore, opts ...Option) (NameSystem, error) { ns.dnsResolver = NewDNSResolver(madns.DefaultResolver.LookupTXT) } - ns.proquintResolver = new(ProquintResolver) ns.ipnsResolver = NewIpnsResolver(r) ns.ipnsPublisher = NewIpnsPublisher(r, ns.ds) @@ -188,7 +185,6 @@ func (ns *mpns) resolveOnceAsync(ctx context.Context, name string, options opts. // Resolver selection: // 1. if it is a PeerID/CID/multihash resolve through "ipns". // 2. if it is a domain name, resolve through "dns" - // 3. otherwise resolve through the "proquint" resolver var res resolver ipnsKey, err := peer.Decode(key) @@ -228,11 +224,9 @@ func (ns *mpns) resolveOnceAsync(ctx context.Context, name string, options opts. } else if _, ok := dns.IsDomainName(key); ok { res = ns.dnsResolver } else { - // TODO: remove proquint? - // dns.IsDomainName(key) will return true for proquint strings, - // so this block is a dead code. - // (alternative is to move this before DNS check) - res = ns.proquintResolver + out <- onceResult{err: fmt.Errorf("invalid IPNS root: %q", key)} + close(out) + return out } resCh := res.resolveOnceAsync(ctx, key, options) diff --git a/namesys/proquint.go b/namesys/proquint.go deleted file mode 100644 index b918ec986..000000000 --- a/namesys/proquint.go +++ /dev/null @@ -1,34 +0,0 @@ -package namesys - -import ( - "context" - "errors" - - proquint "github.com/bren2010/proquint" - path "github.com/ipfs/go-path" - opts "github.com/ipfs/interface-go-ipfs-core/options/namesys" -) - -// ProquintResolver implements the Resolver interface for proquint identifiers -// (see http://arxiv.org/html/0901.4016). -type ProquintResolver struct{} - -// Resolve implements Resolver. -func (r *ProquintResolver) Resolve(ctx context.Context, name string, options ...opts.ResolveOpt) (path.Path, error) { - return resolve(ctx, r, name, opts.ProcessOpts(options)) -} - -// resolveOnce implements resolver. Decodes the proquint string. -func (r *ProquintResolver) resolveOnceAsync(ctx context.Context, name string, options opts.ResolveOpts) <-chan onceResult { - out := make(chan onceResult, 1) - defer close(out) - - ok, err := proquint.IsProquint(name) - if err != nil || !ok { - out <- onceResult{err: errors.New("not a valid proquint string")} - return out - } - // Return a 0 TTL as caching this result is pointless. - out <- onceResult{value: path.FromString(string(proquint.Decode(name)))} - return out -}