libp2p
    Preparing search index...

    Module @libp2p/memory

    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 10s
    const connection = await dialer.dial(ma, {
    signal: AbortSignal.timeout(10_000)
    })

    // use connection...

    @libp2p/memory

    libp2p.io Discuss codecov CI

    A memory transport for libp2p

    About

    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 10s
    const connection = await dialer.dial(ma, {
    signal: AbortSignal.timeout(10_000)
    })

    // use connection...

    Install

    $ npm i @libp2p/memory
    

    Loading this module through a script tag will make its exports available as Libp2pMemory in the global namespace.

    <script src="https://unpkg.com/@libp2p/memory/dist/index.min.js"></script>
    

    API Docs

    License

    Licensed under either of

    Contribution

    Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

    Interfaces

    MemoryTransportComponents
    MemoryTransportInit

    Functions

    memory