Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
feat(EnumLinksAsync): Remove error since it's unused
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahhoward committed Oct 29, 2018
1 parent 269f6d2 commit c54d0e4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 20 deletions.
13 changes: 5 additions & 8 deletions hamt/hamt.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ import (
cid "github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"
dag "github.com/ipfs/go-merkledag"
"github.com/spaolacci/murmur3"

format "github.com/ipfs/go-unixfs"
"github.com/spaolacci/murmur3"
)

const (
Expand Down Expand Up @@ -401,10 +400,8 @@ func (ds *Shard) getValue(ctx context.Context, hv *hashBits, key string, cb func
func (ds *Shard) EnumLinks(ctx context.Context) ([]*ipld.Link, error) {
var links []*ipld.Link

linkResults, err := ds.EnumLinksAsync(ctx)
if err != nil {
return nil, err
}
linkResults := ds.EnumLinksAsync(ctx)

for linkResult := range linkResults {
if linkResult.Err != nil {
return links, linkResult.Err
Expand All @@ -426,7 +423,7 @@ func (ds *Shard) ForEachLink(ctx context.Context, f func(*ipld.Link) error) erro

// EnumLinksAsync returns a channel which will receive Links in the directory
// as they are enumerated, where order is not gauranteed
func (ds *Shard) EnumLinksAsync(ctx context.Context) (<-chan format.LinkResult, error) {
func (ds *Shard) EnumLinksAsync(ctx context.Context) <-chan format.LinkResult {
linkResults := make(chan format.LinkResult)
ctx, cancel := context.WithCancel(ctx)
go func() {
Expand All @@ -439,7 +436,7 @@ func (ds *Shard) EnumLinksAsync(ctx context.Context) (<-chan format.LinkResult,
emitResult(ctx, linkResults, format.LinkResult{Link: nil, Err: err})
}
}()
return linkResults, nil
return linkResults
}

// makeAsyncTrieGetLinks builds a getLinks function that can be used with EnumerateChildrenAsync
Expand Down
6 changes: 2 additions & 4 deletions hamt/hamt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,8 @@ func TestEnumLinksAsync(t *testing.T) {
t.Fatal(err)
}

linkResults, err := nds.EnumLinksAsync(ctx)
if err != nil {
t.Fatal(err)
}
linkResults := nds.EnumLinksAsync(ctx)

var linksB []*ipld.Link

for linkResult := range linkResults {
Expand Down
8 changes: 4 additions & 4 deletions io/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type Directory interface {

// EnumLinksAsync returns a channel which will receive Links in the directory
// as they are enumerated, where order is not gauranteed
EnumLinksAsync(context.Context) (<-chan format.LinkResult, error)
EnumLinksAsync(context.Context) <-chan format.LinkResult

// Links returns the all the links in the directory node.
Links(context.Context) ([]*ipld.Link, error)
Expand Down Expand Up @@ -148,7 +148,7 @@ func (d *BasicDirectory) AddChild(ctx context.Context, name string, node ipld.No

// EnumLinksAsync returns a channel which will receive Links in the directory
// as they are enumerated, where order is not gauranteed
func (d *BasicDirectory) EnumLinksAsync(ctx context.Context) (<-chan format.LinkResult, error) {
func (d *BasicDirectory) EnumLinksAsync(ctx context.Context) <-chan format.LinkResult {
linkResults := make(chan format.LinkResult)
go func() {
defer close(linkResults)
Expand All @@ -163,7 +163,7 @@ func (d *BasicDirectory) EnumLinksAsync(ctx context.Context) (<-chan format.Link
}
}
}()
return linkResults, nil
return linkResults
}

// ForEachLink implements the `Directory` interface.
Expand Down Expand Up @@ -253,7 +253,7 @@ func (d *HAMTDirectory) ForEachLink(ctx context.Context, f func(*ipld.Link) erro

// EnumLinksAsync returns a channel which will receive Links in the directory
// as they are enumerated, where order is not gauranteed
func (d *HAMTDirectory) EnumLinksAsync(ctx context.Context) (<-chan format.LinkResult, error) {
func (d *HAMTDirectory) EnumLinksAsync(ctx context.Context) <-chan format.LinkResult {
return d.shard.EnumLinksAsync(ctx)
}

Expand Down
5 changes: 1 addition & 4 deletions io/directory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,7 @@ func TestDirBuilder(t *testing.T) {
t.Fatal("wrong number of links", len(links), count)
}

linkResults, err := dir.EnumLinksAsync(ctx)
if err != nil {
t.Fatal(err)
}
linkResults := dir.EnumLinksAsync(ctx)

asyncNames := make(map[string]bool)
var asyncLinks []*ipld.Link
Expand Down

0 comments on commit c54d0e4

Please sign in to comment.