Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

feat!: rename peer discovery symbol to peerDiscovery #394

Merged
merged 2 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 2 additions & 4 deletions packages/interface-mocks/src/peer-discovery.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { symbol } from '@libp2p/interface-peer-discovery'
import { peerDiscovery } from '@libp2p/interface-peer-discovery'
import { EventEmitter } from '@libp2p/interfaces/events'
import * as PeerIdFactory from '@libp2p/peer-id-factory'
import { multiaddr } from '@multiformats/multiaddr'
Expand All @@ -24,9 +24,7 @@ export class MockDiscovery extends EventEmitter<PeerDiscoveryEvents> implements
this._isRunning = false
}

readonly [symbol] = true

readonly [Symbol.toStringTag] = 'MockDiscovery'
readonly [peerDiscovery] = this

start (): void {
this._isRunning = true
Expand Down
18 changes: 1 addition & 17 deletions packages/interface-peer-discovery/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,8 @@ import type { EventEmitter } from '@libp2p/interfaces/events'
*/
export const peerDiscovery = Symbol.for('@libp2p/peer-discovery')

export const symbol = Symbol.for('@libp2p/peer-discovery')

export interface PeerDiscoveryEvents {
'peer': CustomEvent<PeerInfo>
}

export interface PeerDiscovery extends EventEmitter<PeerDiscoveryEvents> {
/**
* Used to identify the peer discovery mechanism
*/
[Symbol.toStringTag]: string

/**
* Used by the isPeerDiscovery function
*/
[symbol]: true
}

export function isPeerDiscovery (other: any): other is PeerDiscovery {
return other != null && Boolean(other[symbol])
}
export interface PeerDiscovery extends EventEmitter<PeerDiscoveryEvents> {}