Refactor: simplify session peer management#275
Conversation
|
@Stebalien |
| haves = interestedRes[1] | ||
| dontHaves = interestedRes[2] | ||
| // s.logReceiveFrom(from, ks, haves, dontHaves) | ||
|
|
There was a problem hiding this comment.
I moved the isNewPeer check below to be inside sessionPeerSender as it simplifies the logic there and consolidates changes to session peers in one place
| if len(ks) == 0 { | ||
| return | ||
| } | ||
|
|
There was a problem hiding this comment.
I moved the chunk of code below to be inside the run loop so we can get rid of locking
| s.periodicSearchTimer.Reset(s.periodicSearchDelay.NextWaitTime()) | ||
| } | ||
|
|
||
| // findMorePeers attempts to find more peers for a session by searching for |
There was a problem hiding this comment.
I brought this function from inside of the SessionPeerManager to be in the Session instead, as it makes it easier to follow whats going on and simplifies the dependencies between Session, sessionWantSender and SessionPeerManager
| @@ -12,7 +11,6 @@ import ( | |||
| // sessionWants keeps track of which cids are waiting to be sent out, and which | |||
| // peers are "live" - ie, we've sent a request but haven't received a block yet | |||
| type sessionWants struct { | |||
There was a problem hiding this comment.
The changes in sessionWants is basically just removing a bunch of locks that we no longer need as everything is inside the Session run loop now
Refactor: simplify session peer management This commit was moved from ipfs/go-bitswap@981dfb1
This refactor simplifies session peer management by