Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save RandyMcMillan/3acc32cc6791c7e9a0e8532711fb3e04 to your computer and use it in GitHub Desktop.

Select an option

Save RandyMcMillan/3acc32cc6791c7e9a0e8532711fb3e04 to your computer and use it in GitHub Desktop.
var hypercore = require('hypercore')
var ram = require('random-access-memory')
var feed = hypercore(ram)
feed.append('hello world')
var swarm = require('webrtc-swarm')
var signalhub = require('signalhub')
feed.on('ready', function () {
var hub = signalhub(feed.discoveryKey.toString('hex'), ['https://signalhub.mafintosh.com'])
var sw = swarm(hub)
sw.on('peer', function (peer, id) {
console.log('connected to a new peer:', id)
peer.pipe(feed.replicate({encrypt: false})).pipe(peer)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment