hypercore-protocol / cli

A CLI for peer-to-peer file sharing using the Hypercore Protocol.
MIT License
206 stars 17 forks source link

how to sync bee #46

Open shikhars371 opened 3 years ago

shikhars371 commented 3 years ago

hi here is my backend.js

const { Client } = require('hyperspace') const HyperBee = require('hyperbee') const { kvPairs : dictionaryPairs } = require('websters-english-dictionary')

start()

async function start() { const { corestore, replicate } = new Client() const store = corestore()

const core = store.get({ name: 'dictionary' })

const db = new HyperBee(core, { keyEncoding: 'utf-8', valueEncoding: 'utf-8' })

const batch = db.batch() for (const { key, value } of dictionaryPairs()) { await batch.put(key, value) }

await batch.flush()

//print bee key console.log(' bee ', db.feed.key.toString('hex'))

// Now announce on hyp await replicate(core) }

when i am running this code its giving me a console a key on console :

ba118da4eb768dde70d6c1e016ff5b26f3e97ef91ff097c9f21d7c4f8c4699e1 I am seeding the above key as : hyp seed ba118da4eb768dde70d6c1e016ff5b26f3e97ef91ff097c9f21d7c4f8c4699e1

now on second server i am doing :: hyp sync ba118da4eb768dde70d6c1e016ff5b26f3e97ef91ff097c9f21d7c4f8c4699e1 ------ above line giving me error: root@tower6:~# hyp sync ba118da4eb768dde70d6c1e016ff5b26f3e97ef91ff097c9f21d7c4f8c4699e1 Error: The hyper:// was expected to be a hyperdrive, got hyperbee

please help me how to seed and sync bee

Octalbyte commented 2 years ago

Hi @shikhars371 ! There is an issue on the CLI command of the second server. The command hyp sync [key] is an alias for hyp drive sync [key]. sync does not work for bees. The commands available for hyperbee are: image The error has none to do with the backend.js code. I hope this helps.