Skip to content

Commit

Permalink
namesys: review fixes
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 Oct 16, 2018
1 parent 94bbeff commit fa3e9b9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
1 change: 0 additions & 1 deletion core/coreapi/interface/name.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package iface

import (
"context"

"errors"

options "github.com/ipfs/go-ipfs/core/coreapi/interface/options"
Expand Down
3 changes: 1 addition & 2 deletions core/coreapi/name.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"strings"
"time"

ipath "gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path"

"github.com/ipfs/go-ipfs/core"
coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface"
caopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options"
Expand All @@ -18,6 +16,7 @@ import (
"gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto"
"gx/ipfs/QmQ9PR61a8rwEFuFNs7JMA1QtQC9yZnBwoDn51JWXDbaTd/go-ipfs-routing/offline"
"gx/ipfs/QmbNepETomvmXfz1X5pHNFD2QuPqnqi47dTd94QJWSorQ3/go-libp2p-peer"
ipath "gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path"
)

type NameAPI CoreAPI
Expand Down
2 changes: 1 addition & 1 deletion core/corehttp/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (m mockNamesys) ResolveAsync(ctx context.Context, name string, opts ...nsop
v, err := m.Resolve(ctx, name, opts...)
out <- namesys.Result{Path: v, Err: err}
close(out)
return nil
return out
}

func (m mockNamesys) Publish(ctx context.Context, name ci.PrivKey, value path.Path) error {
Expand Down
16 changes: 9 additions & 7 deletions namesys/base.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package namesys

import (
"context"
"strings"
"time"

context "context"

opts "github.com/ipfs/go-ipfs/namesys/opts"

path "gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path"
)

Expand Down Expand Up @@ -40,13 +40,10 @@ func resolve(ctx context.Context, r resolver, name string, options opts.ResolveO
return p, err
}

//TODO:
// - better error handling
// - select on writes
func resolveAsync(ctx context.Context, r resolver, name string, options opts.ResolveOpts, prefix string) <-chan Result {
resCh := r.resolveOnceAsync(ctx, name, options)
depth := options.Depth
outCh := make(chan Result)
outCh := make(chan Result, 1)

go func() {
defer close(outCh)
Expand Down Expand Up @@ -97,8 +94,13 @@ func resolveAsync(ctx context.Context, r resolver, name string, options opts.Res
break
}

outCh <- res
select {
case outCh <- res:
case <-ctx.Done():
return
}
case <-ctx.Done():
return
}
if resCh == nil && subCh == nil {
return
Expand Down
1 change: 1 addition & 0 deletions namesys/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"

opts "github.com/ipfs/go-ipfs/namesys/opts"

isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain"
path "gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path"
)
Expand Down

0 comments on commit fa3e9b9

Please sign in to comment.