orbitdb / field-manual

The Offical User's Guide to OrbitDB
210 stars 44 forks source link

How does OrbitDB update the heads (tails?) (oplog?) on immutable IPFS #124

Open filoozom opened 3 years ago

filoozom commented 3 years ago

Hi,

I've tried looking a bit at the code and in this repo, but I'm struggling to find out how OrbitDB is able to keep a constant address on IPFS, which should be immutable.

How can you append to /orbitdb/cid/db? I didn't find any reference to IPNS, but I'm assuming there has to be something like that somewhere?

Thanks!

CSDUMMI commented 3 years ago

OrbitDB uses PubSub channels to communicate the CIDs of tail objects. These objects then reference those objects before them.

The name of the PubSub channel is stored or derived from the manifest.

An example manifest looks like this:

{
  value: {
    name: 'abc',
    type: 'eventlog',
    accessController: '/ipfs/zdpuAyXXyGF4wDnpoV1hnQAT3HrBdnNh27aW9tYzJk1w1pL9B'
  },
  remainderPath: ''
}

And the AC Object then looks like this:

{
  value: {
    type: 'ipfs',
    params: { address: 'zdpuAsngiZH1NMErdZKjrC5DGEb78yvHvGwxe76YiUXTbNE96' }
  },
  remainderPath: ''
}
CSDUMMI commented 3 years ago

Actually the stringified address of the database is used as the PubSub Channel name.

astudnev commented 2 years ago

This explains the topic, but does not tell how we can rely on this PubSub mechanics on real production system.