From 7f2ed7f0e555dbdb8180b96ea335ccaffd2d9de4 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Wed, 11 Oct 2023 19:21:12 +0100 Subject: [PATCH] fix!: remove dialler language (#2143) Co-authored-by: Chad Nehemiah Co-authored-by: Cayman --- doc/migrations/v0.46-v1.0.md | 53 +++++++++++++++++++ .../src/connection-manager/dial-queue.ts | 4 +- .../test/connection-manager/auto-dial.spec.ts | 40 +++++++------- 3 files changed, 75 insertions(+), 22 deletions(-) create mode 100644 doc/migrations/v0.46-v1.0.md diff --git a/doc/migrations/v0.46-v1.0.md b/doc/migrations/v0.46-v1.0.md new file mode 100644 index 0000000000..184b266cf0 --- /dev/null +++ b/doc/migrations/v0.46-v1.0.md @@ -0,0 +1,53 @@ + +# Migrating to libp2p@1.0 + +A migration guide for refactoring your application code from libp2p v0.46 to v1.0. + +## Table of Contents + +- [API](#api) +- [Module Updates](#module-updates) +- [Metrics](#metrics) + +## API + + + +## Module Updates + +With this release you should update the following libp2p modules if you are relying on them: + + + +```json + +``` + +## Metrics + +The following metrics were renamed: + +`libp2p_dialler_pending_dials` => `libp2p_dial_queue_pending_dials` +`libp2p_dialler_in_progress_dials` => `libp2p_dial_queue_in_progress_dials` diff --git a/packages/libp2p/src/connection-manager/dial-queue.ts b/packages/libp2p/src/connection-manager/dial-queue.ts index 280e677c02..a724796406 100644 --- a/packages/libp2p/src/connection-manager/dial-queue.ts +++ b/packages/libp2p/src/connection-manager/dial-queue.ts @@ -103,8 +103,8 @@ export class DialQueue { setMaxListeners(Infinity, this.shutDownController.signal) - this.pendingDialCount = components.metrics?.registerMetric('libp2p_dialler_pending_dials') - this.inProgressDialCount = components.metrics?.registerMetric('libp2p_dialler_in_progress_dials') + this.pendingDialCount = components.metrics?.registerMetric('libp2p_dial_queue_pending_dials') + this.inProgressDialCount = components.metrics?.registerMetric('libp2p_dial_queue_in_progress_dials') this.pendingDials = [] for (const [key, value] of Object.entries(init.resolvers ?? {})) { diff --git a/packages/libp2p/test/connection-manager/auto-dial.spec.ts b/packages/libp2p/test/connection-manager/auto-dial.spec.ts index 9e45ae8c7b..9019890e61 100644 --- a/packages/libp2p/test/connection-manager/auto-dial.spec.ts +++ b/packages/libp2p/test/connection-manager/auto-dial.spec.ts @@ -22,7 +22,7 @@ import type { PeerStore, Peer } from '@libp2p/interface/peer-store' import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' describe('auto-dial', () => { - let autoDialler: AutoDial + let autoDialer: AutoDial let events: TypedEventTarget let peerStore: PeerStore let peerId: PeerId @@ -38,8 +38,8 @@ describe('auto-dial', () => { }) afterEach(() => { - if (autoDialler != null) { - autoDialler.stop() + if (autoDialer != null) { + autoDialer.stop() } }) @@ -73,7 +73,7 @@ describe('auto-dial', () => { getDialQueue: Sinon.stub().returns([]) }) - autoDialler = new AutoDial({ + autoDialer = new AutoDial({ peerStore, connectionManager, events @@ -81,8 +81,8 @@ describe('auto-dial', () => { minConnections: 10, autoDialInterval: 10000 }) - autoDialler.start() - void autoDialler.autoDial() + autoDialer.start() + void autoDialer.autoDial() await pWaitFor(() => { return connectionManager.openConnection.callCount === 1 @@ -127,15 +127,15 @@ describe('auto-dial', () => { getDialQueue: Sinon.stub().returns([]) }) - autoDialler = new AutoDial({ + autoDialer = new AutoDial({ peerStore, connectionManager, events }, { minConnections: 10 }) - autoDialler.start() - await autoDialler.autoDial() + autoDialer.start() + await autoDialer.autoDial() await pWaitFor(() => connectionManager.openConnection.callCount === 1) await delay(1000) @@ -181,15 +181,15 @@ describe('auto-dial', () => { }]) }) - autoDialler = new AutoDial({ + autoDialer = new AutoDial({ peerStore, connectionManager, events }, { minConnections: 10 }) - autoDialler.start() - await autoDialler.autoDial() + autoDialer.start() + await autoDialer.autoDial() await pWaitFor(() => connectionManager.openConnection.callCount === 1) await delay(1000) @@ -207,7 +207,7 @@ describe('auto-dial', () => { getDialQueue: Sinon.stub().returns([]) }) - autoDialler = new AutoDial({ + autoDialer = new AutoDial({ peerStore, connectionManager, events @@ -215,12 +215,12 @@ describe('auto-dial', () => { minConnections: 10, autoDialInterval: 10000 }) - autoDialler.start() + autoDialer.start() // call autodial twice await Promise.all([ - autoDialler.autoDial(), - autoDialler.autoDial() + autoDialer.autoDial(), + autoDialer.autoDial() ]) // should only have queried peer store once @@ -258,7 +258,7 @@ describe('auto-dial', () => { getDialQueue: Sinon.stub().returns([]) }) - autoDialler = new AutoDial({ + autoDialer = new AutoDial({ peerStore, connectionManager, events @@ -266,9 +266,9 @@ describe('auto-dial', () => { minConnections: 10, autoDialPeerRetryThreshold: 2000 }) - autoDialler.start() + autoDialer.start() - void autoDialler.autoDial() + void autoDialer.autoDial() await pWaitFor(() => { return connectionManager.openConnection.callCount === 1 @@ -282,7 +282,7 @@ describe('auto-dial', () => { await delay(2000) // autodial again - void autoDialler.autoDial() + void autoDialer.autoDial() await pWaitFor(() => { return connectionManager.openConnection.callCount === 3