Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Does Orbit DB only sync after a write? #62

Open
@DanielVF

Description

@DanielVF

In the OrbitDB docs, I read: "In order to have the same data, ie. a query returns the same result for all peers, an OrbitDB database must be replicated between the peers. This happens automatically in OrbitDB in a way that a peer only needs to open an OrbitDB from an address and it'll start replicating the database."

However, the behavior I'm seeing while testing this locally is that when I merely open a DB, no syncing happens.

I have one IPFS server, one Orbit Database, two local instances of that database, each one with some heads that the other does not have has. I start up both instances, and no message are sent on IPFS PubSub, and both DB's remain unsynced.

If I do a write at the point that both are online, they both pickup that new head, and follow the next's back from that write. But merely opening a database connecting does not sync.

Is this intended behavior? Could this be due to my local DB's instances using the same user public key? And/or is this because I'm sharing a remote IPFS server?

Source below:

const IpfsApi = require('ipfs-api')
const OrbitDB = require('orbit-db')

const ipfs = IpfsApi('localhost', '5001')
const orbitdb = new OrbitDB(ipfs)

async function run(){
    const db = await orbitdb.open('/orbitdb/MYDBHASHHERE/test-db')
    await db.load()

    const result = db.iterator({ limit: -1 }).collect()
    console.log("Start")
    console.log(JSON.stringify(result, null, 2))

    db.events.on('replicated', (address) => {
        console.log("REPLICATED")
        console.log(db.iterator({ limit: -1 }).collect())
    })
}

run()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions