JSPM

libp2p-exchange-direct

0.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q36412F
  • License MIT

Data Exchange component that uses the swarm to directly dial the taget peer if it is connected

Package Exports

  • libp2p-exchange-direct

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (libp2p-exchange-direct) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

libp2p-exchange-direct

Data Exchange component that uses the swarm to directly dial the taget peer if it is connected

Use-Case

The use case for this exchange component is to allow quick upgrades of a libp2p-circuit connection using transports that require the data-exchange component.

Example

'use strict'

const Exchange = require('libp2p-exchange-direct')

const exchangeA = new Exchange(swarmA)
const exchangeB = new Exchange(swarmB)

exchangeA.start(() => {})
exchangeB.start(() => {})

exchangeB.listen('example', (data, cb) => {
  return cb(null, data.reverse())
})

swarmA.dial(swarmB.peerInfo, err => {
  if (err) throw err

  exchangeA.request(swarmB.peerInfo.id, 'example', Buffer.from('Hello World!'), console.log)
})