Skip to content

Latest commit

 

History

History
123 lines (92 loc) · 3.02 KB

v0.30-v0.31.md

File metadata and controls

123 lines (92 loc) · 3.02 KB

Migrating to libp2p@31

A migration guide for refactoring your application code from libp2p v0.30.x to v0.31.0.

Table of Contents

Types

Most of the type definitions in the libp2p configuration were any or were not included before this release. This might cause breaking changes on upstream projects relying on the previous provided types, as well as to libp2p modules implemented by the libp2p community.

API

Core API

libp2p.dialProtocol does not accept empty or null protocols returning a connection anymore and dial must be used instead.

const connection = await libp2p.dialProtocol(peerId)

After

const connection = await libp2p.dial(peerId)

Connection Manager Options

We updated the connection manager options naming in [email protected] but kept it backward compatible until now.

Before

const node = await Libp2p.create({
  connectionManager: {
    minPeers: 0
  }
})

After

const node = await Libp2p.create({
  connectionManager: {
    minConnections: 0
  }
})

You can see full details on how to configure the connection manager here.

Dialer and Keychain components

Internal property names to create a libp2p Dialer and Keychain were updated to reflect the properties naming in the libp2p configuration. These are internal modules of libp2p core and should not impact most of the users, but as it is possible to use them separately here follow the changes:

*Before

const dialer = new Dialer({
  transportManager,
  peerStore,
  concurrency,
  perPeerLimit,
  timeout,
  resolvers,
  addressSorter
})

const keychain = new Keychain(datastore, {
  passPhrase
})

After

this.dialer = new Dialer({
  transportManager,
  peerStore,
  maxParallelDials,
  maxDialsPerPeer,
  dialTimeout,
  resolvers,
  addressSorter
})

const keychain = new Keychain(datastore, {
  pass
})

Module Updates

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

"libp2p-bootstrap": "^0.12.3",
"libp2p-crypto": "^0.19.4",
"libp2p-interfaces": "^0.10.0",
"libp2p-delegated-content-routing": "^0.10.0",
"libp2p-delegated-peer-routing": "^0.9.0",
"libp2p-floodsub": "^0.25.1",
"libp2p-gossipsub": "^0.9.0",
"libp2p-kad-dht": "^0.22.0",
"libp2p-mdns": "^0.16.0",
"libp2p-noise": "^3.0.0",
"libp2p-tcp": "^0.15.4",
"libp2p-webrtc-star": "^0.22.2",
"libp2p-websockets": "^0.15.6"

One of the main changes in this new release is the update to [email protected]. This should also be updated in upstream projects to avoid several multiaddr versions in the bundle and to avoid potential problems when libp2p interacts with provided outdated multiaddr instances.