Created
January 10, 2019 11:17
-
-
Save latenssi/557b02e910327c9d1ccd1130130b8f9c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const IPFS = require("ipfs"); | |
const OrbitDB = require("orbit-db"); | |
const ipfs = new IPFS({ | |
repo: "./ipfs", | |
EXPERIMENTAL: { | |
pubsub: true | |
} | |
}); | |
ipfs.once("ready", async () => { | |
try { | |
const orbitdb1 = await OrbitDB.createInstance(ipfs); | |
const db1 = await orbitdb1.log("test"); | |
await db1.add({ content: 1 }); | |
await db1.close(); | |
await orbitdb1.disconnect(); | |
const orbitdb2 = await OrbitDB.createInstance(ipfs); | |
const db2 = await orbitdb2.log("test"); | |
db2.events.on("load.progress", (...args) => { | |
console.log(args[2].payload.value); | |
}); | |
await db2.load(-1); | |
await db2.close(); | |
await orbitdb2.disconnect(); | |
} catch (e) { | |
console.error(e); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment