"First shared hypercore must be the same" when trying to replicate via webrtc.
See original GitHub issueI’m trying to replicate a db over webrtc-swarm
and always running into the dreaded “First shared hypercore must be the same” message.
Below is the code I am trying to use. I use the same key for both dbs, and as far as i can tell i am looping both replication streams similarly to the tcp example in #19 .
Does anyone notice anything I’m doing wrong?
const wrtc = require('wrtc')
const swarm = require('webrtc-swarm')
const signalhub = require('signalhub')
const hyperdb = require('hyperdb')
const db1 = init_db('./db1', { valueEncoding: 'utf-8' })
db1.on('ready', () => {
const db2 = init_db('./db2', db1.key, { valueEncoding: 'utf-8' })
db2.on('ready', () => {
db1.put('/hello', 'world', () => {
init_swarm(db1, (hub) => {
return swarm(hub, {
wrtc: wrtc
})
})
init_swarm(db2, (hub) => {
return swarm(hub, {
wrtc: wrtc
})
})
})
})
})
function init_swarm(db, swarmfn) {
const hub = signalhub('freemate', ['https://signalhub.mafintosh.com'])
const sw = swarmfn(hub)
sw.on('peer', (peer, id) => {
console.log('found peer')
const repstream = db.replicate()
peer.on('data', (data) => {
console.log('id: ', id, ' got data: ', data)
})
repstream.pipe(peer).pipe(repstream)
peer.once('finish', (err) => console.log(err))
peer.once('error', (err) => console.log(err))
})
return sw
}
function init_db(location) {
const db = hyperdb(location, { valueEncoding: 'utf-8' })
return db
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Issues with dat project's hyperdb in browser with webrtc and ...
I'm trying to use hyperdb in browser with swarming via webrtc and signalhub. The code is pretty strait forward, but there is some...
Read more >Yjs/community - Gitter
Hi all, how is it possible to get a CodeMirror example working using WebRTC instead of WebSockets? This is my first node project...
Read more >Dripline: Check the specs: final thoughts on p2p options
One metric that's useful to consider when choosing protocols is overall performance. What feels “fast” when a user tries to load data? How...
Read more >p2p Databases - Hyperbee - workshop
BitTorrent lets you download large files in pieces from different ... WebRTC enables browsers to share video, audio, and data between ...
Read more >Data Architecture | community - GitHub Pages
How is Hypercore different from BitTorrent, WebTorrent? ... Using Hypercore data structures community produced replicated databases KappaDB and multi- ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@peacememories once you figure this out, I’d love to see your example!
@peacememories it’s part of the capability system and to have a joint discovery key. the first one to create the db, becomes the source. this simply means that the discoveryKey of the first one is the discovery key for the db forever. the first writer can disappear though without any issues.