Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go-libp2p-kad-dht: implement GetValuesAsync #49

Closed
wants to merge 3 commits into from

Conversation

mildred
Copy link

@mildred mildred commented Feb 22, 2017

For #47

return vals, nil
}

func (dht *IpfsDHT) GetValuesAsync(ctx context.Context, key string, nvals int) <-chan *routing.RecvdVal {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whyrusleeping:

Maybe we want to return a channel of 'maybe values' that have either a RecvdVal or an error? Might make the handling of errors a bit simpler

mildred:

Yes, perhaps, but I didn't know so I took the same approach as FindProvidersAsync. I'm ready to change that if you think so.

mildred/ipfs-objects@39c20b2#diff-50d2a8e6d11e785b103932ac6c926e72R169

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You added the error field into the RecvdVal in the routing interface PR. Should we make use of it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, I see getValuesAsyncRoutine will use it if error channel is not specified. Should we use it instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will use both

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mildred is the errChan ever used? It seems a bit redundant at this point

@@ -226,14 +273,12 @@ func (dht *IpfsDHT) GetValues(ctx context.Context, key string, nvals int) ([]rou

// run it!
_, err = query.Run(ctx, rtp)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whyrusleeping:

I think its probably bad that we ignore this error if we got at least one response back... I think this should be addressed separately

mildred:

Why do you say it's ignored? The fact is we must respond asynchronously to errors, and this one will appear at the very last moment. We cannot return it directly, this function is in a goroutine.

mildred/ipfs-objects@39c20b2#diff-50d2a8e6d11e785b103932ac6c926e72R274

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case where sentRes != 0, we never return the error from Run

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few days ago, I understood more from your remark. I just fixed an issue where sentRes wasn't incremented when needed (it collects the number of results sent).

However, when there is no result, we might get an error from the lower layers, but that doesn't necessarily mean the GetValues must return an error. Instead it might mean that there is no result at all and we must not trigger an error. The previous version of the code silents some errors in this case, I see no reason to change that in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mildred right, i was mostly commenting that the existing behaviour might be incorrect. We can always change it in a different PR though.

@whyrusleeping whyrusleeping added the status/deferred Conscious decision to pause or backlog label Oct 17, 2017
@magik6k magik6k mentioned this pull request Jul 17, 2018
@Stebalien
Copy link
Member

Replaced by SearchValues.

@Stebalien Stebalien closed this Aug 30, 2018
@ghost ghost removed the status/deferred Conscious decision to pause or backlog label Aug 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants