-
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
refactor: peerConnector #665
Conversation
Jenkins BuildsClick to see older builds (18)
|
bf3e9b5
to
5219e7b
Compare
Not sure. IIUC, peers from the subscription be consumed only while the peerConnector is running. If so, the worst that could happen is that you end up receiving peers that are not online when the peerConnector runs again, and you'd waste some seconds while attempting to connect to them. |
GroupPeersByDirection is just grouping all peers we are connected to. There can be peers which is not a relayPeer and can just be providing other Waku services only. So, would not recommend renaming it. Also note that, the current peerMgmt implementation is tied with managing relay peer connections. In future this will get expanded to manage connections towards other service peers 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.
Nice PR.
Cleans up some of the remnants of code which i missed removing.
Currently peerConector is paused when inDirectionPeer > inRelayPeersTarget. Whereas at another place in peerManager, we have similar check inRelayPeer>pm.InRelayPeersTarget. There after getting the direction peers we also filter by proto(/relay/2.0.0 in this case). |
PeerConnector is paused when outPeersTarget is reached. Whereas in peerManager we have checks for both inPeers and outPeers target. |
Sorry, i confused with inRelay.
|
Now i see what you are referring to. Understood. |
Understanding:
why does subscriptions array in Peerconnector exist?
Reason: if Peerconnector isn't running and either of the peer discovery protocols (rendezvous/peer_exchange/discv5) adds a subscription. that subscription needs to be stored. So that once peer connector is running we can start getting peers from these saved subscriptions.
Why are there different peerCh and dialCh channels?
Reason: peerCh also have origin information that has to be added to peerManager. Where is dialCh is peerInfo field of peerCh which is only used for establishing connection.
why are there workerCtx, workerCancel and shouldDialPeers?
Reason: if no of outConnection exceeds outRelayTarget, then pause.
Let's consider host connected relay peers are more than outRelayTarget, then shouldDialPeers will pause PeerConnector. Since peerCh is unbuffered, this will block rendezvous(https://github.com/waku-org/go-waku/blob/master/waku/v2/rendezvous/rendezvous.go#L95). Not block peer_exchange(as response is handled asynchronisely)/discv5(async runDiscoveryV5Loop-> peerLoop-> peerConnector.Subscribe)
it can happen that one of goroutine ends after the peerCh or dialCh is closed. So it might type to send to that routine which will panic.
Problem with workerCtx, scenario:
This new peer will not make the connection even though it is saved in host due to AddDiscoveredPeer call.
Questions: