@cryptotaxi247 / kubo / commits / 8e4ce426a

namesys: use routing.SearchValue

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>

Łukasz Magiera committed Sep 24, 2018 at 16:12 UTC 8e4ce426a49be469f359d8d0bbde20a7e5b7bffa
2 files changed +11 -22
core/commands/name/ipns.go
+10 -9
@@ -159,16 +159,17 @@ Resolve the value of a dnslink:
159 }
160
161 return cmds.EmitOnce(res, &ResolvedPath{output})
162 - } else {
163 - output := resolver.ResolveAsync(req.Context, name, ropts...)
164 - for v := range output {
165 - if v.Err != nil {
166 - return err
167 - }
168 - if err := res.Emit(&ResolvedPath{v.Path}); err != nil {
169 - return err
170 - }
162 + }
163 +
164 + output := resolver.ResolveAsync(req.Context, name, ropts...)
165 + for v := range output {
166 + if v.Err != nil {
167 + return err
168 }
169 + if err := res.Emit(&ResolvedPath{v.Path}); err != nil {
170 + return err
171 + }
172 +
173 }
174 return nil
175 },
namesys/routing.go
+1 -13
@@ -11,7 +11,6 @@ import (
11 cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid"
12 mh "gx/ipfs/QmPnFwZ2JXKnXgMw8CdBPxn7FWh6LLdjUjxV1fKHuJnkr8/go-multihash"
13 routing "gx/ipfs/QmVBnJDKhtFXTRVjXKinqpwGu8t1DyNqPKan2iGX8PR8xG/go-libp2p-routing"
14 - ropts "gx/ipfs/QmVBnJDKhtFXTRVjXKinqpwGu8t1DyNqPKan2iGX8PR8xG/go-libp2p-routing/options"
14 logging "gx/ipfs/QmZChCsSt8DctjceaL56Eibc29CVQq4dGKRXC5JRZ6Ppae/go-log"
15 dht "gx/ipfs/QmZVakpN44VAUxs9eXAuUGLFYTCGmSyqSy6hyEKfMv68ME/go-libp2p-kad-dht"
16 ipns "gx/ipfs/QmZrmn2BPZbSviQAWeyY2iXkCukmJHv9n7zrLgWU5KgbTb/go-ipns"
@@ -89,7 +88,7 @@ func (r *IpnsResolver) resolveOnceAsync(ctx context.Context, name string, option
88 // the value, which in turn verifies the ipns record signature
89 ipnsKey := ipns.RecordKey(pid)
90
92 - vals, err := r.searchValue(ctx, ipnsKey, dht.Quorum(int(options.DhtRecordCount)))
91 + vals, err := r.routing.SearchValue(ctx, ipnsKey, dht.Quorum(int(options.DhtRecordCount)))
92 if err != nil {
93 log.Debugf("RoutingResolver: dht get for name %s failed: %s", name, err)
94 out <- onceResult{err: err}
@@ -173,14 +172,3 @@ func (r *IpnsResolver) resolveOnceAsync(ctx context.Context, name string, option
172
173 return out
174 }
176 -
177 -func (r *IpnsResolver) searchValue(ctx context.Context, key string, opts ...ropts.Option) (<-chan []byte, error) {
178 - if ir, ok := r.routing.(*dht.IpfsDHT); ok {
179 - return ir.SearchValue(ctx, key, opts...)
180 - }
181 - out := make(chan []byte, 1)
182 - val, err := r.routing.GetValue(ctx, key, opts...)
183 - out <- val
184 - close(out)
185 - return out, err
186 -}