hyperswarm / replicator

Replicate data structures easily using hyperswarm
44 stars 14 forks source link

example #2

Open xloem opened 3 years ago

xloem commented 3 years ago

I'm having some trouble getting connected. Is there a simple known-working example to compare with?

mafintosh commented 3 years ago

you can try the imdb mirror 46190f4a2daaaae53689d292501f18b8e0302dc9344e3756d8ec7a2d03cb5348

xloem commented 3 years ago

I mean, a simple sourcefile that runs successfully?

mafintosh commented 3 years ago

You can wrap that in a hypercore:

const hypercore = require('hypercore')
const feed = hypercore('feed', '46190f4a2daaaae53689d292501f18b8e0302dc9344e3756d8ec7a2d03cb5348')

require('@hyperswarm/replicator')(feed, { lookup: true, announce: false })

feed.get(0, function (err, data) {
  console.log(err, data)
})