Revision 81846eee5f732b319a5a084f5f26ea3f87035ebf authored by Jeromy on 11 February 2017, 21:51:48 UTC, committed by Jeromy on 11 February 2017, 21:55:38 UTC
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
1 parent 466429c
Raw File
proquint.go
package namesys

import (
	"errors"

	context "context"
	path "github.com/ipfs/go-ipfs/path"
	proquint "gx/ipfs/QmYnf27kzqR2cxt6LFZdrAFJuQd6785fTkBvMuEj9EeRxM/proquint"
)

type ProquintResolver struct{}

// Resolve implements Resolver.
func (r *ProquintResolver) Resolve(ctx context.Context, name string) (path.Path, error) {
	return r.ResolveN(ctx, name, DefaultDepthLimit)
}

// ResolveN implements Resolver.
func (r *ProquintResolver) ResolveN(ctx context.Context, name string, depth int) (path.Path, error) {
	return resolve(ctx, r, name, depth, "/ipns/")
}

// resolveOnce implements resolver. Decodes the proquint string.
func (r *ProquintResolver) resolveOnce(ctx context.Context, name string) (path.Path, error) {
	ok, err := proquint.IsProquint(name)
	if err != nil || !ok {
		return "", errors.New("not a valid proquint string")
	}
	return path.FromString(string(proquint.Decode(name))), nil
}
back to top