-
Notifications
You must be signed in to change notification settings - Fork 42
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: enable event emission for peer discovery/connection in ConnectionManager #1438
Conversation
size-limit report 📦
|
const peersConnectedByPeerExchange: Peer[] = []; | ||
|
||
for (const peer of peersDiscovered) { | ||
const tags = await this.getTagNamesForPeer(peer.id); |
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.
you don't need to use getTagNamesForPeer
but you can directly refer to peer.tags.keys()
to avoid async operation
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.
it is done to keep fetching tags consistent through this function; agreed that it is async, but it is computationally low demand so should be ok
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 am wondering what is the difference if the same tags
are present on peer
in the loop as well as those you'd get from this.getTagNamesForPeer
?
@@ -44,12 +52,57 @@ export class ConnectionManager { | |||
return instance; | |||
} | |||
|
|||
public async getPeersByDiscovery(): Promise<PeersByDiscovery> { | |||
const peersDiscovered = await this.libp2p.peerStore.all(); | |||
const peersConnected = this.libp2p |
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 guess we can optimize here and just getConnections
which returns tags as well so that later there is no reason to await for peer store
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.
correct. that is a more efficient way, agreed.
related comment: #1438 (comment)
Thank you for promptly addressing the comments! |
353d819
to
9d777c9
Compare
Problem
This PR aims to make the process of finding/displaying total peers found via a discovery protocol vs actually connected.
It is part of https://github.com/orgs/waku-org/projects/2/views/1?pane=issue&itemId=26409725
Solution
ConnectionManager
to emit events as a new peer is discovered/connectedNotes