Skip to content

Commit

Permalink
fix!: forward connection manager events on and update types (#1524)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: the connection manager and registrar are internal types and as such not part of the libp2p interface, instead use the methods exposed on the root libp2p type for obtaining connections and protocols (see the upgrade guide)
  • Loading branch information
achingbrain committed Dec 21, 2022
1 parent 57a56aa commit 58cc480
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/libp2p.ts
Expand Up @@ -132,6 +132,14 @@ export class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {
// Create the Connection Manager
this.connectionManager = this.components.connectionManager = new DefaultConnectionManager(this.components, init.connectionManager)

// forward connection manager events
this.components.connectionManager.addEventListener('peer:disconnect', (event) => {
this.dispatchEvent(new CustomEvent<Connection>('peer:disconnect', { detail: event.detail }))
})
this.components.connectionManager.addEventListener('peer:connect', (event) => {
this.dispatchEvent(new CustomEvent<Connection>('peer:connect', { detail: event.detail }))
})

// Create the Registrar
this.registrar = this.components.registrar = new DefaultRegistrar(this.components)

Expand Down

0 comments on commit 58cc480

Please sign in to comment.