-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Conversation
704ec60
to
197e60f
Compare
If we get this working though, it should make |
There was a problem hiding this 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.
merkledag/merkledag.go
Outdated
@@ -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 { |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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>
197e60f
to
1de040d
Compare
There was a problem hiding this 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.
(except the missing documentation) |
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 thenAdd
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