# Migrating to libp2p@44 <!-- omit in toc -->

A migration guide for refactoring your application code from libp2p v0.43.x to v0.44.0.

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

- [Connection Manager](#connection-manager)
- [Connection Gater](#connection-gater)

## Connection Manager

The connection manager has been refactored to be simpler and faster.  The changes
are mostly internal but some configuration options have changed.

**Before**

```js
import { createLibp2p } from 'libp2p'

const node = await createLibp2p({
  connectionManager: {
    // this has been renamed to `maxPeerAddrsToDial`
    maxAddrsToDial: 20,

    // this has been renamed to `maxParallelDialsPerPeer`
    maxDialsPerPeer: 20,

    // these should now be ranges expressed as MultiaddrFilters
    allow: [
      '/ip4/0.0.0.0/tcp/123'
    ],

    // these should now be ranges expressed as MultiaddrFilters
    deny: [
      '/ip4/0.0.0.0/tcp/123'
    ]
  }
})
```

**After**

```js
import { createLibp2p } from 'libp2p'
import { MultiaddrFilter } from from '@multiformats/multiaddr'

const node = await createLibp2p({
  connectionManager: {
    // how many peers to dial at once while trying to ensure the node
    // is above minConnections
    autoDialConcurrency: 25,

    // a low value allows user-initiated dials to take priority over
    // auto dials
    autoDialPriority: 0,

    // this was previously named `maxAddrsToDial`
    maxPeerAddrsToDial: 20,

    // this was previously named `maxDialsPerPeer`
    maxParallelDialsPerPeer: 20
  }
})
```

## Connection Gater

The `denyDialMultiaddr` method on the `ConnectionGater` interface no longer receives a peer id. This is to
support gating multiaddr dials for multiaddrs without peer ids.

If the peer id is known it will be present in the multiaddr.

**Before**

```js
import { createLibp2p } from 'libp2p'

const node = await createLibp2p({
  connectionGater: {
    denyDialMultiaddr: (peerId, multiaddr) => {
      // allow/deny logic here
    }
  }
})
```

**After**

```js
import { createLibp2p } from 'libp2p'

const node = await createLibp2p({
  connectionGater: {
    denyDialMultiaddr: (multiaddr) => {
      if (multiaddr.getPeerId() != null) {
        // there is a peer id present in the multiaddr
      }

      // allow/deny logic here
    }
  }
})
```
