mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-25 20:37:53 +08:00
simplify routing resolution a bit
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
This commit is contained in:
parent
5dc0b7326e
commit
56232ba4bc
@ -168,24 +168,22 @@ func (r *routingResolver) resolveOnce(ctx context.Context, name string, options
|
||||
return "", err
|
||||
}
|
||||
|
||||
var p path.Path
|
||||
// check for old style record:
|
||||
valh, err := mh.Cast(entry.GetValue())
|
||||
if err != nil {
|
||||
if valh, err := mh.Cast(entry.GetValue()); err == nil {
|
||||
// Its an old style multihash record
|
||||
log.Debugf("encountered CIDv0 ipns entry: %s", valh)
|
||||
p = path.FromCid(cid.NewCidV0(valh))
|
||||
} else {
|
||||
// Not a multihash, probably a new record
|
||||
p, err := path.ParsePath(string(entry.GetValue()))
|
||||
p, err = path.ParsePath(string(entry.GetValue()))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
r.cacheSet(name, p, entry)
|
||||
return p, nil
|
||||
} else {
|
||||
// Its an old style multihash record
|
||||
log.Debugf("encountered CIDv0 ipns entry: %s", valh)
|
||||
p := path.FromCid(cid.NewCidV0(valh))
|
||||
r.cacheSet(name, p, entry)
|
||||
return p, nil
|
||||
}
|
||||
|
||||
r.cacheSet(name, p, entry)
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func checkEOL(e *pb.IpnsEntry) (time.Time, bool) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user