A libp2p transport that operates in-memory only.
This is intended for testing and can only be used to connect two libp2p nodes that are running in the same process.
import { createLibp2p } from 'libp2p'import { memory } from '@libp2p/memory'import { multiaddr } from '@multiformats/multiaddr'const listener = await createLibp2p({ addresses: { listen: [ '/memory/address-a' ] }, transports: [ memory() ]})const dialer = await createLibp2p({ transports: [ memory() ]})const ma = multiaddr('/memory/address-a')// dial the listener, timing out after 10sconst connection = await dialer.dial(ma, { signal: AbortSignal.timeout(10_000)})// use connection... Copy
import { createLibp2p } from 'libp2p'import { memory } from '@libp2p/memory'import { multiaddr } from '@multiformats/multiaddr'const listener = await createLibp2p({ addresses: { listen: [ '/memory/address-a' ] }, transports: [ memory() ]})const dialer = await createLibp2p({ transports: [ memory() ]})const ma = multiaddr('/memory/address-a')// dial the listener, timing out after 10sconst connection = await dialer.dial(ma, { signal: AbortSignal.timeout(10_000)})// use connection...
A libp2p transport that operates in-memory only.
This is intended for testing and can only be used to connect two libp2p nodes that are running in the same process.
Example