-
Notifications
You must be signed in to change notification settings - Fork 112
Bitswap Refactor #1: Session Manager & Extract Want Manager #28
Conversation
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 code looks good to me. The iterate method bugs me a bit but I'd be fine figuring that out later.
sessionmanager/sessionmanager.go
Outdated
|
||
type IterateSessionFunc func(session exchange.Fetcher) | ||
|
||
// SessionsForBlock returns a slice of all sessions that may be interested in the given cid |
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.
Wrong doc comment.
var out []*Session | ||
for _, s := range bs.sessions { | ||
bs.sm.IterateSessions(func(session exchange.Fetcher) { | ||
s := session.(*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.
Having this cast is a bit funky. I get that this is to avoid a dependency issue but I wonder if there's a better way. Would it make sense to move sessions into their own package? That way, SessionManager could operate over concrete sessions.
Unfortunately, I don't think that'll work as Session appears to need access to bitswap internals. An alternative is to create a Session
interface that exposes an InterestedIn
method.
I'd be fine punting these questions till later.
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.
Hey!
Let's punt till later since two PR's forward Sessions end up in their own package, and this cast is gone :)
IterateSessions disappears in a later PR so I wouldn't worry to much about it. I will fix the comment issue though. |
Extract session manager from bitswap Extract session manager & want manager to package Move want manager message queue to seperate file Move Message Queue to subpackage Respond to PR Comments
4d5134c
to
69d063b
Compare
This is mostly just moving code around so I'm going to leave it at one LGTM. |
continues in #29 |
Bitswap Refactor ipfs#1: Session Manager & Extract Want Manager This commit was moved from ipfs/go-bitswap@c9fee08
Goals
Modularize Bitswap in preparation for attempts to optimize bitswap further
child of #26
Implementation