Skip to content
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

Merged
merged 20 commits into from
Jul 26, 2023
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rename peer event result interface
danisharora099 committed Jul 26, 2023

Verified

This commit was signed with the committer’s verified signature.
danisharora099 Danish Arora
commit fb8ae26c0550292861de885a2f4e8319f815ae12
4 changes: 2 additions & 2 deletions packages/core/src/lib/connection_manager.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import {
ConnectionManagerOptions,
IRelay,
PeerEvents,
PeersByDiscovery,
PeersByDiscoveryResult,
} from "@waku/interfaces";
import { Libp2p, Tags } from "@waku/interfaces";
import debug from "debug";
@@ -52,7 +52,7 @@ export class ConnectionManager extends EventEmitter {
return instance;
}

public async getPeersByDiscovery(): Promise<PeersByDiscovery> {
public async getPeersByDiscovery(): Promise<PeersByDiscoveryResult> {
const peersDiscovered = await this.libp2p.peerStore.all();
const peersConnected = this.libp2p
Copy link
Collaborator

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

Copy link
Collaborator Author

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)

.getConnections()
2 changes: 1 addition & 1 deletion packages/interfaces/src/connection_manager.ts
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ export enum PeerEvents {
PEER_CONNECT_PEER_EXCHANGE = "peer:connected:peer-exchange",
}

export interface PeersByDiscovery {
export interface PeersByDiscoveryResult {
DISCOVERED: {
[Tags.BOOTSTRAP]: Peer[];
[Tags.PEER_EXCHANGE]: Peer[];