# Pastebin CnopU84K const IPFS = require('ipfs') const OrbitDB = require('orbit-db') const ipfsOptions = { config: { // overload the default IPFS node config, find defaults at https://github.com/ipfs/js-ipfs/tree/master/src/core/runtime "Addresses": { "Swarm": [ "/ip4/127.0.0.1/tcp/4001", "/ip6/::/tcp/4001", "/ip4/127.0.0.1/tcp/4002/ws" ], "Announce": [], "NoAnnounce": [], "API": "/ip4/127.0.0.1/tcp/5001", "Gateway": "/ip4/127.0.0.1/tcp/8080" } }, EXPERIMENTAL: { pubsub: true } } // Create IPFS instance const ipfs = new IPFS(ipfsOptions) ipfs.on('error', (e) => console.error(e)) ipfs.on('ready', async () => { const id = await ipfs.id() setInterval(async () => { let peers = await ipfs.swarm.peers(); console.log(peers.map((p) => p.addr.toString())); }, 5000); setTimeout(async () => console.log(await ipfs.files.get("QmP29FK9NbdgCe7xJDTax55n6LP227DaK3FsTs4hiGPCUb")), 15000) console.log(id); const orbitdb = new OrbitDB(ipfs, "./testreplicate") console.log("Database created") // Create a database var testDBAddr = "/orbitdb/Qmd7onRynKUWNP13uUu3r5XAio1omL1p1gcohQ2pmH9Z48/27,1,55,92,155,50,179,43,119,14,183,135,207,166,248,239,208,226,218,187,46,89,113,243,89,76,229,216,9,181,101,55" const replicateddb = await orbitdb.log(testDBAddr) await replicateddb.load() console.log("Database loaded") replicateddb.events.on("replicated", (address) => { console.log(replicateddb.iterator({ limit: -1 }).collect()) }) // Add an entry to the database // const hash = await db.add('hello world') // Get last 5 entries // const latest = db.iterator({ limit: 5 }).collect() // console.log(JSON.stringify(latest, null, 2)) })