-
Notifications
You must be signed in to change notification settings - Fork 43
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
feat: support serviceslots in peermanager #631
Conversation
Jenkins BuildsClick to see older builds (55)
|
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.
nice PR.
left some minor comments
@@ -225,6 +225,7 @@ func (c *PeerConnectionStrategy) workPublisher(ctx context.Context) { | |||
case <-ctx.Done(): | |||
return | |||
case p := <-c.peerCh: | |||
//TODO: Modify to use peermanager AddPeer |
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.
Should we create an issue for this TODO?
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 will be taken up during another peer-manager task itself, hence not required.
Just did not want to club it with service slots.
waku/v2/peermanager/peer_manager.go
Outdated
|
||
// RemovePeer deletes peer from the peerStore after disconnecting it. | ||
func (pm *PeerManager) RemovePeer(peerID peer.ID) { | ||
// TODO: Need to handle removePeer also via peermanager |
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.
Should an issue be created to not forget about this?
waku/v2/peermanager/peer_manager.go
Outdated
if proto == WakuRelayIDv200 { | ||
if filteredPeers.Len() > 0 { | ||
pm.logger.Info("Got peer from peerstore", zap.String("peerId", filteredPeers[0].Pretty())) | ||
return filteredPeers[0], nil |
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.
Should a random peer be returned instead to match the function description?
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.
Good catch!
Co-authored-by: richΛrd <[email protected]>
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
Adding discovered peers also moved to peer manager
peerIDs, ok := pm.serviceSlots[proto] | ||
if ok || len(peerIDs) > 0 { | ||
pm.logger.Info("Got peer from service slots", logging.HostID("peer", peerIDs[0])) | ||
return peerIDs[0], nil |
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.
Maybe this should be random here as well? 🤔
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.
I don't see multiple static peers per service being added as of now, hence left it as is.
Anyways instead of random, at a later point we will have scoring and other params based selection.
Description
Added concept of service slots in peer manager similar to waku-org/nwaku#1473.
Also updated Store protocol to use the new selectPeer function from peerManager.
Changes
Keeping the existing selectPeer functionality in utils package. The reason behind this is so that a user can use any of the Waku protocols without initializing a wakunode, but by just initializing a libp2p host. Documentation shall be created to document the usage of g-waku in both ways.
Tests