diff --git a/benchmarks/benchmark-add-go-ipfs.js b/benchmarks/benchmark-add-go-ipfs.js index 0a03871..6f84f1b 100644 --- a/benchmarks/benchmark-add-go-ipfs.js +++ b/benchmarks/benchmark-add-go-ipfs.js @@ -1,6 +1,6 @@ 'use strict' -const IPFS = require('ipfs-api') +const IPFS = require('ipfs-http-client') const OrbitDB = require('../src/OrbitDB') // Metrics @@ -26,8 +26,8 @@ const ipfs = IPFS('127.0.0.1') const run = async () => { try { - const orbit = new OrbitDB(ipfs, './orbitdb/benchmarks') - const db = await orbit.eventlog('orbit-db.benchmark', { + const orbit = await OrbitDB.createInstance(ipfs, { directory: './orbitdb/benchmarks' }) + const db = await orbit.eventlog('orbit-db.benchmark', { replicate: false, }) diff --git a/benchmarks/benchmark-add.js b/benchmarks/benchmark-add.js index 42af87d..a91bf5f 100644 --- a/benchmarks/benchmark-add.js +++ b/benchmarks/benchmark-add.js @@ -44,8 +44,8 @@ ipfs.on('error', (err) => console.error(err)) ipfs.on('ready', async () => { const run = async () => { try { - const orbit = new OrbitDB(ipfs, './orbitdb/benchmarks') - const db = await orbit.eventlog('orbit-db.benchmark', { + const orbit = await OrbitDB.createInstance(ipfs,{ directory: './orbitdb/benchmarks' }) + const db = await orbit.eventlog('orbit-db.benchmark', { replicate: false, }) diff --git a/benchmarks/benchmark-replication-sender.js b/benchmarks/benchmark-replication-sender.js index 7536991..e379410 100644 --- a/benchmarks/benchmark-replication-sender.js +++ b/benchmarks/benchmark-replication-sender.js @@ -46,8 +46,8 @@ const defaultConfig = Object.assign({}, { config: ipfsConf }) -const conf1 = Object.assign({}, defaultConfig, { - repo: new IPFSRepo('./orbitdb/benchmarks/replication/client1/ipfs', repoConf) +const conf1 = Object.assign({}, defaultConfig, { + repo: new IPFSRepo('./orbitdb/benchmarks/replication/client1/ipfs', repoConf) }) // Write loop @@ -74,7 +74,7 @@ const outputMetrics = (name, db, metrics) => { if(metrics.seconds % 10 === 0) { console.log(`[${name}] --> Average of ${metrics.lastTenSeconds/10} q/s in the last 10 seconds`) metrics.lastTenSeconds = 0 - } + } } const database = 'benchmark-replication' @@ -87,7 +87,7 @@ pMapSeries([conf1,], d => startIpfs('js-ipfs', d)) .then(async ([ipfs1]) => { try { // Create the databases - const orbit1 = new OrbitDB(ipfs1.api, './orbitdb/benchmarks/replication/client1') + const orbit1 = await OrbitDB.createInstance(ipfs1.api, { directory: './orbitdb/benchmarks/replication/client1' }) const db1 = await orbit1.eventlog(database, { overwrite: true }) console.log(db1.address.toString()) diff --git a/benchmarks/benchmark-replication.js b/benchmarks/benchmark-replication.js index 0202cb6..eaaf69c 100644 --- a/benchmarks/benchmark-replication.js +++ b/benchmarks/benchmark-replication.js @@ -46,8 +46,8 @@ const defaultConfig = Object.assign({}, { config: ipfsConf }) -const conf2 = Object.assign({}, defaultConfig, { - repo: new IPFSRepo('./orbitdb/benchmarks/replication/client22faf/ipfs', repoConf) +const conf2 = Object.assign({}, defaultConfig, { + repo: new IPFSRepo('./orbitdb/benchmarks/replication/client22faf/ipfs', repoConf) }) // Metrics output function @@ -59,7 +59,7 @@ const outputMetrics = (name, db, metrics) => { if(metrics.seconds % 10 === 0) { console.log(`[${name}] --> Average of ${metrics.lastTenSeconds/10} q/s in the last 10 seconds`) metrics.lastTenSeconds = 0 - } + } } const database = 'benchmark-replication' @@ -72,7 +72,7 @@ pMapSeries([conf2], d => startIpfs('js-ipfs', d)) .then(async ([ipfs2]) => { try { // Create the databases - const orbit2 = new OrbitDB(ipfs2.api, './orbitdb/benchmarks/replication/client2') + const orbit2 = await OrbitDB.createInstance(ipfs2.api, { directory: './orbitdb/benchmarks/replication/client2' }) const address = process.argv[2] const db2 = await orbit2.eventlog(address) diff --git a/benchmarks/browser/benchmark-add.html b/benchmarks/browser/benchmark-add.html index 4c4b064..0c38447 100644 --- a/benchmarks/browser/benchmark-add.html +++ b/benchmarks/browser/benchmark-add.html @@ -32,7 +32,7 @@ } let run = (() => { - ipfs = new Ipfs({ + ipfs = new Ipfs({ repo: '/orbitdb/benchmarks/browser/benchmark-add/0.27.0', start: false, EXPERIMENTAL: { @@ -47,8 +47,8 @@ ipfs.on('ready', async () => { const outputElm = document.getElementById('output') try { - const orbit = new OrbitDB(ipfs, './orbitdb/benchmarks/browser') - const db = await orbit.eventlog('orbit-db.benchmark.add', { + const orbit = await OrbitDB.createInstance(ipfs, { directory: './orbitdb/benchmarks/browser' }) + const db = await orbit.eventlog('orbit-db.benchmark.add', { replicate: false, }) diff --git a/benchmarks/browser/benchmark-replication-sender.html b/benchmarks/browser/benchmark-replication-sender.html index 7eb114e..dd22264 100644 --- a/benchmarks/browser/benchmark-replication-sender.html +++ b/benchmarks/browser/benchmark-replication-sender.html @@ -53,7 +53,7 @@ config: ipfsConf }) - const conf1 = Object.assign({}, defaultConfig, { + const conf1 = Object.assign({}, defaultConfig, { repo: './orbitdb/benchmarks/2replication3/client2/ipfs' }) @@ -77,7 +77,7 @@ if(metrics.seconds % 10 === 0) { console.log(`[${name}] --> Average of ${metrics.lastTenSeconds/10} q/s in the last 10 seconds`) metrics.lastTenSeconds = 0 - } + } } const startIpfs = (config = {}) => { @@ -98,7 +98,7 @@ let ipfs1 = await startIpfs(conf1) try { // Create the databases - const orbit1 = new OrbitDB(ipfs1, './orbitdb/benchmarks/replication/client1') + const orbit1 = await OrbitDB.createInstance(ipfs1, { directory: './orbitdb/benchmarks/replication/client1' }) const db1 = await orbit1.eventlog(database, { overwrite: true, sync: false }) console.log("Database address is:", db1.address.toString()) diff --git a/benchmarks/browser/benchmark-replication.html b/benchmarks/browser/benchmark-replication.html index 4956f95..fddb982 100644 --- a/benchmarks/browser/benchmark-replication.html +++ b/benchmarks/browser/benchmark-replication.html @@ -60,11 +60,11 @@ config: ipfsConf }) - const conf1 = Object.assign({}, defaultConfig, { + const conf1 = Object.assign({}, defaultConfig, { repo: './orbitdb/benchmarks/2replication3/client1/ipfs' }) - const conf2 = Object.assign({}, defaultConfig, { + const conf2 = Object.assign({}, defaultConfig, { repo: './orbitdb/benchmarks/2replication3/client2/ipfs' }) @@ -88,7 +88,7 @@ if(metrics.seconds % 10 === 0) { console.log(`[${name}] --> Average of ${metrics.lastTenSeconds/10} q/s in the last 10 seconds`) metrics.lastTenSeconds = 0 - } + } } const startIpfs = (config = {}) => { @@ -109,8 +109,8 @@ let ipfs2 = await startIpfs(conf2) try { // Create the databases - const address = '/orbitdb/QmcPCAwwV1rw7cLQU7VcCaUXEuLYSCH8uUf6NPDLYbL6JT/benchmark-replication' - const orbit2 = new OrbitDB(ipfs2, './orbitdb/benchmarks/replication/client3') + const address = '/orbitdb/zdpuArNFJaH4Fk5dHH4rYSCtmbyaJLNHUyeFX4WszFxEqwJTE/benchmark-replication' + const orbit2 = await OrbitDB.createInstance(ipfs2, { directory: './orbitdb/benchmarks/replication/client3' }) const db2 = await orbit2.eventlog(address) db2.events.on('peer', peer => console.log("PEER2!", peer)) diff --git a/examples/browser/browser.html b/examples/browser/browser.html index f7cd242..2efe1ed 100644 --- a/examples/browser/browser.html +++ b/examples/browser/browser.html @@ -51,8 +51,8 @@
- - + +