Discussion for https://github.com/Orbitdb/orbit-db. Community docs and CoC at https://github.com/Orbitdb/welcome. FAQ: https://github.com/orbitdb/orbit-db/blob/master/FAQ.md
replicated
event: indeed, this is now sent only when the db has been (fully) replicated. in fact, the previous behaviour wasn't intended (replicated events "chunked"). however, if I understand the need described above, you want to be able to "know when some progress of replication has been made" and the replicate.progress
event will give you that (see https://github.com/orbitdb/orbit-db-store/blob/main/src/Store.js#L100 for the callback signature and params). it's emitted for each replicated db log entry. with that, you can eg. show a nice progress bar, or hook to it to show the replicated data to the user. note though that when replicate.progress
is fired, the DB index hasn't been updated yet with the replicated data.
@u007 What you mean by connecting peers from frontend? If you could share your code, I might help you with that.
@vinkabuki here is my nodejs code with orbitdb
const initIPFSInstance = async () => {
return await IPFS.create({
host: '0.0.0.0',
port: '5001',
protocol: 'http',
repo: './ipfs',
EXPERIMENTAL: { pubsub: true },
});
};
initIPFSInstance().then(async (ipfs) => {
const identity = await Identities.createIdentity({ id: '_cherry' });
console.log('myidentity', identity);
const orbitdb = await OrbitDB.createInstance(ipfs, { identity: identity });
const db = await orbitdb.docs('orbit.users.home.coins', {
accessController: {
write: [orbitdb.identity.id],
read: [
'*'
],
},
});
});
and ive gotten my db address to /orbitdb/zdpuB1GzckVfwJfAZuVr9MwvYdGLk2jDd4jXgLvb4Memgnsip/orbit.users.home.coins
how do i connect via react? i tried
Ipfs.create({
preload: { enabled: false },
repo: './ipfs',
EXPERIMENTAL: { pubsub: true },
config: {
Bootstrap: [],
Addresses: { Swarm: ['localhost'] }
}
})
but i got some error on localhost
@u007 I think I've figured it out, but I'm short in time so you must figure out the last step. Make sure that port is correct (Mine was 5002 instead 5001). What I got is some problem with CORS, you must find a way how to add it and u should be fine.
const { HttpApi } = require('ipfs-http-server')
const { HttpGateway } = require('ipfs-http-gateway')
const initIPFSInstance = async () => {
return await IPFS.create({
host: '0.0.0.0',
port: '5001',
protocol: 'http',
repo: './ipfs',
EXPERIMENTAL: { pubsub: true },
API: {}
});
};
initIPFSInstance().then(async (ipfs) => {
const httpApi = new HttpApi(ipfs)
await httpApi.start()
const httpGateway = new HttpGateway(ipfs)
await httpGateway.start()
const orbitdb = await OrbitDB.createInstance(ipfs);
const db = await orbitdb.docs('orbit.users.home.coins', {
accessController: {
write: ['*'],
read: [
'*'
],
},
});
});
and on frontend:
import { create } from "ipfs-http-client";
const client = create("http://0.0.0.0:5002/api/v0");
const created = await client.add(file);
That's what the do in ipfs deamon - https://github.com/ipfs/js-ipfs/blob/master/packages/ipfs-daemon/src/index.js#L50-L51
And the react part - https://blog.logrocket.com/decentralized-data-storage-using-ipfs-and-react-a-tutorial-with-examples/
lmk if that worked