Documentation / @super-line/adapter-libp2p / createLibp2pAdapter
Function: createLibp2pAdapter()
createLibp2pAdapter(
options?):Promise<Adapter&object>
Defined in: packages/adapter-libp2p/src/index.ts:254
Create a libp2p (gossipsub) Adapter for decentralized, broker-less multi-node fan-out. All channels ride one shared gossipsub topic; each node filters incoming messages by its local subscriptions, so subscribe / unsubscribe are local bookkeeping with no network round-trip. At-most-once delivery, matching the library's model.
Parameters
options?
Libp2pAdapterOptions = {}
Libp2pAdapterOptions (bring your own node, or let the adapter build one and point discovery at how peers find each other).
Returns
Promise<Adapter & object>
Example
ts
// LAN / docker network — peers find each other over multicast, zero addresses
const adapter = await createLibp2pAdapter({ discovery: 'mdns' })
// fixed-seed topology
const adapter = await createLibp2pAdapter({ discovery: { bootstrap: ['/ip4/10.0.0.1/tcp/9001/p2p/12D3Koo…'] } })
// Kubernetes headless Service — every replica is an ephemeral peer
const adapter = await createLibp2pAdapter({
listen: ['/ip4/0.0.0.0/tcp/9001'],
discovery: { dns: { hostname: 'super-line-p2p.default.svc.cluster.local', port: 9001 } },
})
// NAT'd nodes meshing through a public relay (see createRelayNode)
const adapter = await createLibp2pAdapter({ discovery: { relay: '/dns4/relay.example.com/tcp/9000/ws/p2p/12D3Koo…' } })