Use the identify function to add support for the Identify protocol to libp2p.
identify
This protocol allows network peers to discover the multiaddrs the current node listens on, and the protocols it supports.
A second function, identifyPush is also exported to add support for identify/push.
identifyPush
This protocol will send updates to all connected peers when the multiaddrs or protocols of the current node change.
For maximum network compatibility you should configure both protocols
import { createLibp2p } from 'libp2p'import { identify } from '@libp2p/identify'const node = await createLibp2p({ // ...other options services: { identify: identify() }}) Copy
import { createLibp2p } from 'libp2p'import { identify } from '@libp2p/identify'const node = await createLibp2p({ // ...other options services: { identify: identify() }})
import { createLibp2p } from 'libp2p'import { identifyPush } from '@libp2p/identify'const node = await createLibp2p({ // ...other options services: { identifyPush: identifyPush() }}) Copy
import { createLibp2p } from 'libp2p'import { identifyPush } from '@libp2p/identify'const node = await createLibp2p({ // ...other options services: { identifyPush: identifyPush() }})
Use the
identify
function to add support for the Identify protocol to libp2p.This protocol allows network peers to discover the multiaddrs the current node listens on, and the protocols it supports.
A second function,
identifyPush
is also exported to add support for identify/push.This protocol will send updates to all connected peers when the multiaddrs or protocols of the current node change.
For maximum network compatibility you should configure both protocols
Example: Enabling identify
Example: Enabling identify push