Skip to content

Commit

Permalink
namesys: use routing.SearchValue
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
  • Loading branch information
magik6k committed Sep 24, 2018
1 parent fc59660 commit 75175d4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
19 changes: 10 additions & 9 deletions core/commands/name/ipns.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,17 @@ Resolve the value of a dnslink:
}

return cmds.EmitOnce(res, &ResolvedPath{output})
} else {
output := resolver.ResolveAsync(req.Context, name, ropts...)
for v := range output {
if v.Err != nil {
return err
}
if err := res.Emit(&ResolvedPath{v.Path}); err != nil {
return err
}
}

output := resolver.ResolveAsync(req.Context, name, ropts...)
for v := range output {
if v.Err != nil {
return err
}
if err := res.Emit(&ResolvedPath{v.Path}); err != nil {
return err
}

}
return nil
},
Expand Down
13 changes: 1 addition & 12 deletions namesys/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (r *IpnsResolver) resolveOnceAsync(ctx context.Context, name string, option
// the value, which in turn verifies the ipns record signature
ipnsKey := ipns.RecordKey(pid)

vals, err := r.searchValue(ctx, ipnsKey, dht.Quorum(int(options.DhtRecordCount)))
vals, err := r.routing.SearchValue(ctx, ipnsKey, dht.Quorum(int(options.DhtRecordCount)))
if err != nil {
log.Debugf("RoutingResolver: dht get for name %s failed: %s", name, err)
out <- onceResult{err: err}
Expand Down Expand Up @@ -173,14 +173,3 @@ func (r *IpnsResolver) resolveOnceAsync(ctx context.Context, name string, option

return out
}

func (r *IpnsResolver) searchValue(ctx context.Context, key string, opts ...ropts.Option) (<-chan []byte, error) {
if ir, ok := r.routing.(*dht.IpfsDHT); ok {
return ir.SearchValue(ctx, key, opts...)
}
out := make(chan []byte, 1)
val, err := r.routing.GetValue(ctx, key, opts...)
out <- val
close(out)
return out, err
}

0 comments on commit 75175d4

Please sign in to comment.