Commit c54d0e47 authored by hannahhoward's avatar hannahhoward

feat(EnumLinksAsync): Remove error since it's unused

parent 269f6d22
...@@ -29,9 +29,8 @@ import ( ...@@ -29,9 +29,8 @@ import (
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format" ipld "github.com/ipfs/go-ipld-format"
dag "github.com/ipfs/go-merkledag" dag "github.com/ipfs/go-merkledag"
"github.com/spaolacci/murmur3"
format "github.com/ipfs/go-unixfs" format "github.com/ipfs/go-unixfs"
"github.com/spaolacci/murmur3"
) )
const ( const (
...@@ -401,10 +400,8 @@ func (ds *Shard) getValue(ctx context.Context, hv *hashBits, key string, cb func ...@@ -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) { func (ds *Shard) EnumLinks(ctx context.Context) ([]*ipld.Link, error) {
var links []*ipld.Link var links []*ipld.Link
linkResults, err := ds.EnumLinksAsync(ctx) linkResults := ds.EnumLinksAsync(ctx)
if err != nil {
return nil, err
}
for linkResult := range linkResults { for linkResult := range linkResults {
if linkResult.Err != nil { if linkResult.Err != nil {
return links, linkResult.Err return links, linkResult.Err
...@@ -426,7 +423,7 @@ func (ds *Shard) ForEachLink(ctx context.Context, f func(*ipld.Link) error) erro ...@@ -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 // EnumLinksAsync returns a channel which will receive Links in the directory
// as they are enumerated, where order is not gauranteed // 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) linkResults := make(chan format.LinkResult)
ctx, cancel := context.WithCancel(ctx) ctx, cancel := context.WithCancel(ctx)
go func() { go func() {
...@@ -439,7 +436,7 @@ func (ds *Shard) EnumLinksAsync(ctx context.Context) (<-chan format.LinkResult, ...@@ -439,7 +436,7 @@ func (ds *Shard) EnumLinksAsync(ctx context.Context) (<-chan format.LinkResult,
emitResult(ctx, linkResults, format.LinkResult{Link: nil, Err: err}) 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 // makeAsyncTrieGetLinks builds a getLinks function that can be used with EnumerateChildrenAsync
......
...@@ -337,10 +337,8 @@ func TestEnumLinksAsync(t *testing.T) { ...@@ -337,10 +337,8 @@ func TestEnumLinksAsync(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
linkResults, err := nds.EnumLinksAsync(ctx) linkResults := nds.EnumLinksAsync(ctx)
if err != nil {
t.Fatal(err)
}
var linksB []*ipld.Link var linksB []*ipld.Link
for linkResult := range linkResults { for linkResult := range linkResults {
......
...@@ -41,7 +41,7 @@ type Directory interface { ...@@ -41,7 +41,7 @@ type Directory interface {
// EnumLinksAsync returns a channel which will receive Links in the directory // EnumLinksAsync returns a channel which will receive Links in the directory
// as they are enumerated, where order is not gauranteed // 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 returns the all the links in the directory node.
Links(context.Context) ([]*ipld.Link, error) Links(context.Context) ([]*ipld.Link, error)
...@@ -148,7 +148,7 @@ func (d *BasicDirectory) AddChild(ctx context.Context, name string, node ipld.No ...@@ -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 // EnumLinksAsync returns a channel which will receive Links in the directory
// as they are enumerated, where order is not gauranteed // 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) linkResults := make(chan format.LinkResult)
go func() { go func() {
defer close(linkResults) defer close(linkResults)
...@@ -163,7 +163,7 @@ func (d *BasicDirectory) EnumLinksAsync(ctx context.Context) (<-chan format.Link ...@@ -163,7 +163,7 @@ func (d *BasicDirectory) EnumLinksAsync(ctx context.Context) (<-chan format.Link
} }
} }
}() }()
return linkResults, nil return linkResults
} }
// ForEachLink implements the `Directory` interface. // ForEachLink implements the `Directory` interface.
...@@ -253,7 +253,7 @@ func (d *HAMTDirectory) ForEachLink(ctx context.Context, f func(*ipld.Link) erro ...@@ -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 // EnumLinksAsync returns a channel which will receive Links in the directory
// as they are enumerated, where order is not gauranteed // 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) return d.shard.EnumLinksAsync(ctx)
} }
......
...@@ -158,10 +158,7 @@ func TestDirBuilder(t *testing.T) { ...@@ -158,10 +158,7 @@ func TestDirBuilder(t *testing.T) {
t.Fatal("wrong number of links", len(links), count) t.Fatal("wrong number of links", len(links), count)
} }
linkResults, err := dir.EnumLinksAsync(ctx) linkResults := dir.EnumLinksAsync(ctx)
if err != nil {
t.Fatal(err)
}
asyncNames := make(map[string]bool) asyncNames := make(map[string]bool)
var asyncLinks []*ipld.Link var asyncLinks []*ipld.Link
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment