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

refactor merkledag fetching methods #2384

Merged
merged 5 commits into from
Feb 29, 2016
Merged

refactor merkledag fetching methods #2384

merged 5 commits into from
Feb 29, 2016

Conversation

whyrusleeping
Copy link
Member

I refactored the dagservice have one new GetMany method that just mimics the interface of the blockservices similar method. It takes some keys and returns a channel of nodes in no particular order.

I then removed the GetDAG and GetNodes methods from the dagservice interface and refactored them to GetMany.

finally, I refactored FetchGraph to use GetMany, and in doing so, it has better error cases (can actually fail through from the blockservice layer) and uses wayyyy fewer goroutines. (though still a good number of them).

cc @noffle @lgierth for CR
cc @mildred since youre working on similar cleanup type stuff

License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
@whyrusleeping
Copy link
Member Author

this should also make pinning suck less (hopefully)

@mildred mildred mentioned this pull request Feb 20, 2016
@mildred
Copy link
Contributor

mildred commented Feb 20, 2016

That's nice. It might also be interesting to deprecate the AddRecursive() and RemoveRecursive() methods to use something like this instead, but what you did was a good first step.

@whyrusleeping
Copy link
Member Author

@mildred oh yeah, those recursive methods arent even used, are they?

License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
@whyrusleeping
Copy link
Member Author

mmm, this ones not quite ready yet. now that things can fail instead of hang, its flushing out new failures in the pinning sharness tests: https://travis-ci.org/ipfs/go-ipfs/jobs/110680509

@mildred
Copy link
Contributor

mildred commented Feb 22, 2016

The RemoveRecursive method isn't used at all and AddRecursive is used 8 times only, and 7 of those are in tests. This can all be easily refactored to use Add instead.

return
}
select {
case out <- nd:
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be a common go-ism, but humour me: why not use a buffered channel for out? This secondary select would be unnecessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

hrm, i guess the improved simplicity there would outweigh any performance gains this might have. I generally avoid buffering channels, but it makes sense here

License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
case b, ok := <-blocks:
if !ok {
if count != len(keys) {
errs <- fmt.Errorf("failed to fetch all nodes")
Copy link
Member

Choose a reason for hiding this comment

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

Failed to fetch all nodes.

Copy link
Member Author

Choose a reason for hiding this comment

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

go's error string convention is lower case with no punctuation: https://github.com/golang/lint/blob/master/lint.go#L1173

@hackergrrl
Copy link
Contributor

🐴 LGTM

License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
@mildred
Copy link
Contributor

mildred commented Feb 25, 2016

Looks good

whyrusleeping added a commit that referenced this pull request Feb 29, 2016
refactor merkledag fetching methods
@whyrusleeping whyrusleeping merged commit dede20e into master Feb 29, 2016
@whyrusleeping whyrusleeping deleted the feat/dag-refactor branch February 29, 2016 18:04
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