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

Use a bitswap session for 'Cat' #4641

Merged
merged 2 commits into from
Feb 3, 2018
Merged

Use a bitswap session for 'Cat' #4641

merged 2 commits into from
Feb 3, 2018

Conversation

whyrusleeping
Copy link
Member

I'm actually not happy with how this turned out. Everything worked out fine until I had to deal with the Hamt code. Theres no distinction between reading from a hamt and writing to it. The solution i chose here was to separate that out, its a bit messy. The other approach would be to just make a hybrid DagService implementation that passes all Get calls to an underlying session, and then Add calls get routed normally. I think that method seems a lot cleaner...

cc @Stebalien @magik6k @kevina let me know what you all think.

License: MIT
Signed-off-by: Jeromy jeromyj@gmail.com

@whyrusleeping
Copy link
Member Author

If we get this working though, it should make ipfs cat and fetching things through the gateway a bit faster.

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

The other approach would be to just make a hybrid DagService implementation that passes all Get calls to an underlying session, and then Add calls get routed normally.

I agree. This also makes progress towards #4138.

I'd kind of like a simple hamt reader (so we traverse read-only filesystems) but we can do that later.

@@ -146,6 +146,15 @@ func (sg *sesGetter) GetMany(ctx context.Context, keys []*cid.Cid) <-chan *ipld.
return getNodesFromBG(ctx, sg.bs, keys)
}

func NewSession(ctx context.Context, dag ipld.DAGService) ipld.NodeGetter {
Copy link
Member

@Stebalien Stebalien Feb 2, 2018

Choose a reason for hiding this comment

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

  • This should probably take a NodeGetter (unless we make sessions full DAGServices).
  • Docs are nice. What happens when the context is canceled? What happens to in-flight requests (esp if we just return the dag and not a session)?

Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, we could define a new interface:

type Session interface {
	Session(ctx context.Context) ipld.NodeGetter
}
func NewSession(ctx context.Context, dag ipld.NodeGetter) ipld.NodeGetter {
	if ses, ok := dag.(Session); ok {
    	return ses.Session(ctx)
    }
    return dag
}

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

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

This is actually kind of beautiful.

@Stebalien
Copy link
Member

(except the missing documentation)

License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
@whyrusleeping whyrusleeping merged commit 79072dc into master Feb 3, 2018
@ghost ghost removed the status/in-progress In progress label Feb 3, 2018
@whyrusleeping whyrusleeping deleted the feat/cat-sessions branch February 3, 2018 23:24
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.

3 participants