Skip to content

Commit

Permalink
fix!: remove dialler language (#2143)
Browse files Browse the repository at this point in the history
Co-authored-by: Chad Nehemiah <chad.nehemiah94@gmail.com>
Co-authored-by: Cayman <caymannava@gmail.com>
  • Loading branch information
3 people committed Nov 3, 2023
1 parent 78b61a2 commit 7f2ed7f
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 22 deletions.
53 changes: 53 additions & 0 deletions doc/migrations/v0.46-v1.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!--Specify versions for migration below-->
# Migrating to libp2p@1.0 <!-- omit in toc -->

A migration guide for refactoring your application code from libp2p v0.46 to v1.0.

## Table of Contents <!-- omit in toc -->

- [API](#api)
- [Module Updates](#module-updates)
- [Metrics](#metrics)

## API

<!--Describe breaking APIs with examples for Before and After
Example:
### Peer Discovery
__Describe__
**Before**
```js
```
**After**
```js
```
-->

## Module Updates

With this release you should update the following libp2p modules if you are relying on them:

<!--Specify module versions in JSON for migration below.
It's recommended to check package.json changes for this:
`git diff <release> <prev> -- package.json`
-->

```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`
4 changes: 2 additions & 2 deletions packages/libp2p/src/connection-manager/dial-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? {})) {
Expand Down
40 changes: 20 additions & 20 deletions packages/libp2p/test/connection-manager/auto-dial.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Libp2pEvents>
let peerStore: PeerStore
let peerId: PeerId
Expand All @@ -38,8 +38,8 @@ describe('auto-dial', () => {
})

afterEach(() => {
if (autoDialler != null) {
autoDialler.stop()
if (autoDialer != null) {
autoDialer.stop()
}
})

Expand Down Expand Up @@ -73,16 +73,16 @@ describe('auto-dial', () => {
getDialQueue: Sinon.stub().returns([])
})

autoDialler = new AutoDial({
autoDialer = new AutoDial({
peerStore,
connectionManager,
events
}, {
minConnections: 10,
autoDialInterval: 10000
})
autoDialler.start()
void autoDialler.autoDial()
autoDialer.start()
void autoDialer.autoDial()

await pWaitFor(() => {
return connectionManager.openConnection.callCount === 1
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -207,20 +207,20 @@ describe('auto-dial', () => {
getDialQueue: Sinon.stub().returns([])
})

autoDialler = new AutoDial({
autoDialer = new AutoDial({
peerStore,
connectionManager,
events
}, {
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
Expand Down Expand Up @@ -258,17 +258,17 @@ describe('auto-dial', () => {
getDialQueue: Sinon.stub().returns([])
})

autoDialler = new AutoDial({
autoDialer = new AutoDial({
peerStore,
connectionManager,
events
}, {
minConnections: 10,
autoDialPeerRetryThreshold: 2000
})
autoDialler.start()
autoDialer.start()

void autoDialler.autoDial()
void autoDialer.autoDial()

await pWaitFor(() => {
return connectionManager.openConnection.callCount === 1
Expand All @@ -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
Expand Down

0 comments on commit 7f2ed7f

Please sign in to comment.