mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-26 12:57:44 +08:00
Reverts the changes that allowed small keys (ed25519 keys) to be inlined. License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
34 lines
1017 B
Go
34 lines
1017 B
Go
package namesys
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
proquint "gx/ipfs/QmYnf27kzqR2cxt6LFZdrAFJuQd6785fTkBvMuEj9EeRxM/proquint"
|
|
path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path"
|
|
|
|
opts "github.com/ipfs/go-ipfs/namesys/opts"
|
|
)
|
|
|
|
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
|
|
}
|