Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Allow for custom libp2p generator in configuration #1463

Closed
@jacobheun

Description

@jacobheun

Currently libp2p is being created by configuration when ipfs boots. This makes it difficult for users to do anything custom with libp2p, even just adding transports that require the nodes peerInfo on startup, libp2p/js-libp2p#222.

By allowing users to specify a generator for libp2p we provide more flexibility for them to customize it to their needs.

It would be great if users could do something like this:

const ipfs = new IPFS({
    libp2p: (_ipfs) => {
      /* Fancy stuff here with startup info from the ipfs node */

      return new Libp2p({
        peerInfo: _ipfs._peerInfo,
        peerBook: _ipfs._peerInfoBook,
        config: { /* custom config using the above fancy stuff */ }
      })
    }
  })

Then when ipfs goes to start libp2p, https://github.com/ipfs/js-ipfs/blob/v0.30.1/src/core/components/libp2p.js#L11, we can run the generator which would have access to boot time information like the nodes peerInfo.

Metadata

Metadata

Assignees

Labels

P2Medium: Good to have, but can wait until someone steps upexp/noviceSomeone with a little familiarity can pick up

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions