Skip to content

Instantly share code, notes, and snippets.

@latenssi
Created January 10, 2019 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save latenssi/557b02e910327c9d1ccd1130130b8f9c to your computer and use it in GitHub Desktop.
Save latenssi/557b02e910327c9d1ccd1130130b8f9c to your computer and use it in GitHub Desktop.
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