mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-03-30 15:08:28 +00:00
Merge remote-tracking branch 'origin/dignifiedquire-ipfs'
This commit is contained in:
commit
c69f0187ef
34966
dist/orbitdb.js
vendored
34966
dist/orbitdb.js
vendored
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const ipfsd = require('ipfsd-ctl');
|
||||
// const ipfsd = require('ipfsd-ctl');
|
||||
const IPFS = require('ipfs')
|
||||
const OrbitDB = require('../src/OrbitDB');
|
||||
const Timer = require('./Timer');
|
||||
|
||||
@ -19,13 +20,17 @@ const startIpfs = () => {
|
||||
// if(err) console.error(err);
|
||||
// resolve(ipfs);
|
||||
// });
|
||||
ipfsd.local((err, node) => {
|
||||
if(err) reject(err);
|
||||
node.startDaemon((err, ipfs) => {
|
||||
if(err) reject(err);
|
||||
resolve(ipfs);
|
||||
});
|
||||
});
|
||||
// ipfsd.local((err, node) => {
|
||||
// if(err) reject(err);
|
||||
// node.startDaemon((err, ipfs) => {
|
||||
// if(err) reject(err);
|
||||
// resolve(ipfs);
|
||||
// });
|
||||
// });
|
||||
const ipfs = new IPFS()
|
||||
ipfs.goOnline(() => {
|
||||
resolve(ipfs)
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const IpfsApi = require('ipfs-api');
|
||||
// const IpfsApi = require('ipfs-api');
|
||||
const IPFS = require('exports?Ipfs!ipfs/dist/index.js')
|
||||
const Logger = require('logplease');
|
||||
const logger = Logger.create("orbit-db example", { color: Logger.Colors.Green, showTimestamp: false, showLevel: false });
|
||||
const OrbitDB = require('../src/OrbitDB');
|
||||
@ -13,7 +14,7 @@ const key = 'greeting';
|
||||
const value = 'Hello world';
|
||||
|
||||
try {
|
||||
const ipfs = IpfsApi();
|
||||
const ipfs = new IPFS();
|
||||
OrbitDB.connect(network, username, password, ipfs).then((orbit) => {
|
||||
orbit.kvstore(channel).then((db) => {
|
||||
let count = 1;
|
||||
@ -31,7 +32,7 @@ try {
|
||||
logger.debug(`${key} | ${result}`);
|
||||
logger.debug("---------------------------------------------------")
|
||||
console.log('\n');
|
||||
}).catch((e) => logger.error(e));
|
||||
}).catch((e) => logger.error(e.stack));
|
||||
};
|
||||
setInterval(query, 1000);
|
||||
});
|
||||
|
178658
examples/bundle.js
178658
examples/bundle.js
File diff suppressed because one or more lines are too long
@ -2,6 +2,7 @@
|
||||
|
||||
const async = require('asyncawait/async');
|
||||
const await = require('asyncawait/await');
|
||||
// const IPFS = require('ipfs')
|
||||
const ipfsd = require('ipfsd-ctl');
|
||||
const OrbitDB = require('../src/OrbitDB');
|
||||
const Timer = require('./Timer');
|
||||
@ -20,6 +21,10 @@ const startIpfs = () => {
|
||||
if(err) console.error(err);
|
||||
resolve(ipfs);
|
||||
});
|
||||
// const ipfs = new IPFS()
|
||||
// ipfs.goOnline(() => {
|
||||
// resolve(ipfs)
|
||||
// })
|
||||
});
|
||||
};
|
||||
|
||||
|
16
package.json
16
package.json
@ -14,10 +14,10 @@
|
||||
"main": "src/OrbitDB.js",
|
||||
"dependencies": {
|
||||
"logplease": "^1.2.6",
|
||||
"orbit-db-counterstore": "0.0.8",
|
||||
"orbit-db-eventstore": "0.0.9",
|
||||
"orbit-db-feedstore": "0.0.9",
|
||||
"orbit-db-kvstore": "0.0.8",
|
||||
"orbit-db-counterstore": "0.0.10",
|
||||
"orbit-db-eventstore": "0.0.11",
|
||||
"orbit-db-feedstore": "0.0.11",
|
||||
"orbit-db-kvstore": "0.0.10",
|
||||
"socket.io-client": "^1.4.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -26,14 +26,16 @@
|
||||
"babel-loader": "^6.2.4",
|
||||
"babel-plugin-transform-runtime": "^6.8.0",
|
||||
"babel-preset-es2015": "^6.6.0",
|
||||
"ipfs-api": "^3.0.2",
|
||||
"ipfsd-ctl": "^0.13.0",
|
||||
"exports-loader": "^0.6.3",
|
||||
"ipfs": "^0.6.1",
|
||||
"ipfs-api": "^4.1.0",
|
||||
"ipfsd-ctl": "^0.14.0",
|
||||
"json-loader": "^0.5.4",
|
||||
"lodash": "^4.3.0",
|
||||
"mocha": "^2.4.5",
|
||||
"orbit-server": "^0.2.3",
|
||||
"stream-http": "^2.2.1",
|
||||
"webpack": "^1.12.15"
|
||||
"webpack": "^2.1.0-beta.7"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
|
@ -45,7 +45,7 @@ class OrbitDB {
|
||||
|
||||
_createStore(Store, dbname, options) {
|
||||
if(!options) options = {};
|
||||
const replicate = options.subscribe ? options.subscribe : true;
|
||||
const replicate = options.subscribe !== undefined ? options.subscribe : true;
|
||||
const store = new Store(this._ipfs, this.user.username, dbname, options);
|
||||
this.stores[dbname] = store;
|
||||
return this._subscribe(store, dbname, replicate);
|
||||
@ -111,13 +111,17 @@ class OrbitDB {
|
||||
|
||||
const readNetworkInfo = (hash) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._ipfs.cat(hash).then((res) => {
|
||||
let buf = '';
|
||||
res
|
||||
.on('error', (err) => reject(err))
|
||||
.on('data', (data) => buf += data)
|
||||
.on('end', () => resolve(buf))
|
||||
}).catch((e) => reject(e));
|
||||
// this._ipfs.cat(hash).then((res) => {
|
||||
// let buf = '';
|
||||
// res
|
||||
// .on('error', (err) => reject(err))
|
||||
// .on('data', (data) => buf += data)
|
||||
// .on('end', () => resolve(buf))
|
||||
// }).catch((e) => reject(e));
|
||||
resolve(JSON.stringify({
|
||||
name: 'localhost dev network',
|
||||
publishers: ['localhost:3333']
|
||||
}))
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -7,38 +7,65 @@ const assert = require('assert');
|
||||
const async = require('asyncawait/async');
|
||||
const await = require('asyncawait/await');
|
||||
const ipfsd = require('ipfsd-ctl');
|
||||
const IPFS = require('ipfs')
|
||||
const OrbitDB = require('../src/OrbitDB');
|
||||
const OrbitServer = require('orbit-server/src/server');
|
||||
|
||||
// Mute logging
|
||||
// require('logplease').setLogLevel('ERROR');
|
||||
require('logplease').setLogLevel('ERROR');
|
||||
|
||||
// Orbit
|
||||
const network = 'Qmeh6ktQ1YFKksugJb59vBxG51xXoEvjBZXRK3DdrF3mNj';
|
||||
const username = 'testrunner';
|
||||
const password = '';
|
||||
|
||||
const startIpfs = () => {
|
||||
let ipfs, ipfsDaemon;
|
||||
const IpfsApis = [
|
||||
// {
|
||||
// // js-ipfs
|
||||
// start: () => {
|
||||
// return new Promise((resolve, reject) => {
|
||||
// const IPFS = require('ipfs')
|
||||
// const ipfs = new IPFS();
|
||||
// ipfs.goOnline((err) => {
|
||||
// if(err) reject(err)
|
||||
// else resolve(ipfs)
|
||||
// });
|
||||
// });
|
||||
// },
|
||||
// stop: () => new Promise((resolve, reject) => ipfs.goOffline(resolve))
|
||||
// },
|
||||
{
|
||||
// js-ipfs-api via local daemon
|
||||
start: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
// OrbitServer.start();
|
||||
ipfsd.disposableApi((err, ipfs) => {
|
||||
if(err) console.error(err);
|
||||
resolve(ipfs);
|
||||
});
|
||||
// ipfsd.local((err, node) => {
|
||||
// if(err) reject(err);
|
||||
// node.startDaemon((err, ipfs) => {
|
||||
// ipfsDaemon = node;
|
||||
// ipfsDaemon.startDaemon((err, ipfs) => {
|
||||
// if(err) reject(err);
|
||||
// resolve(ipfs);
|
||||
// });
|
||||
// });
|
||||
});
|
||||
};
|
||||
},
|
||||
stop: () => Promise.resolve()
|
||||
// stop: () => new Promise((resolve, reject) => ipfsDaemon.stopDaemon(resolve))
|
||||
}
|
||||
];
|
||||
|
||||
OrbitServer.start();
|
||||
|
||||
IpfsApis.forEach(function(ipfsApi) {
|
||||
|
||||
describe('Orbit Client', function() {
|
||||
this.timeout(30000);
|
||||
this.timeout(40000);
|
||||
|
||||
let ipfs, client, client2, db;
|
||||
let client, client2, db;
|
||||
let channel = 'abcdefghijklmn';
|
||||
const cacheFile = path.join(process.cwd(), '/test', 'orbit-db-test-cache.json');
|
||||
|
||||
@ -46,11 +73,11 @@ describe('Orbit Client', function() {
|
||||
this.timeout(20000);
|
||||
|
||||
try {
|
||||
ipfs = await(startIpfs());
|
||||
ipfs = await(ipfsApi.start());
|
||||
// const str = fs.readFileSync('./test/network.json', 'utf-8');
|
||||
// const networkData = new Buffer(JSON.stringify({ Data: str }));
|
||||
const networkFile = await(ipfs.add(path.resolve(process.cwd(), './test/network.json')));
|
||||
assert.equal(networkFile[0].Hash, network);
|
||||
// const networkFile = await(ipfs.add(path.resolve(process.cwd(), './test/network.json')));
|
||||
// assert.equal(networkFile[0].Hash, network);
|
||||
client = await(OrbitDB.connect(network, username, password, ipfs, { allowOffline: true }));
|
||||
client2 = await(OrbitDB.connect(network, username + "2", password, ipfs, { allowOffline: true }));
|
||||
} catch(e) {
|
||||
@ -61,10 +88,12 @@ describe('Orbit Client', function() {
|
||||
done();
|
||||
}));
|
||||
|
||||
after(() => {
|
||||
after(async((done) => {
|
||||
if(db) db.delete();
|
||||
if(client) client.disconnect();
|
||||
});
|
||||
await(ipfsApi.stop());
|
||||
done();
|
||||
}));
|
||||
|
||||
/*
|
||||
describe('API', function() {
|
||||
@ -640,3 +669,5 @@ describe('Orbit Client', function() {
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -5,9 +5,10 @@ const path = require('path');
|
||||
const fs = require('fs');
|
||||
const Promise = require('bluebird');
|
||||
const rimraf = require('rimraf')
|
||||
const ipfsd = require('ipfsd-ctl');
|
||||
const OrbitDB = require('../src/OrbitDB');
|
||||
const OrbitServer = require('orbit-server/src/server');
|
||||
const ipfsd = require('ipfsd-ctl');
|
||||
const IPFS = require('ipfs')
|
||||
|
||||
// Mute logging
|
||||
require('logplease').setLogLevel('ERROR');
|
||||
@ -15,37 +16,57 @@ require('logplease').setLogLevel('ERROR');
|
||||
const network = 'Qmeh6ktQ1YFKksugJb59vBxG51xXoEvjBZXRK3DdrF3mNj';
|
||||
const username = 'testrunner';
|
||||
const username2 = 'rennurtset';
|
||||
|
||||
const ipfsPath = '/tmp/orbittests';
|
||||
|
||||
const startIpfs = () => {
|
||||
let ipfs, ipfsDaemon;
|
||||
const IpfsApis = [
|
||||
// {
|
||||
// // js-ipfs
|
||||
// start: () => {
|
||||
// return new Promise((resolve, reject) => {
|
||||
// const IPFS = require('ipfs')
|
||||
// const ipfs = new IPFS();
|
||||
// ipfs.goOnline(() => resolve(ipfs));
|
||||
// });
|
||||
// },
|
||||
// stop: () => new Promise((resolve, reject) => ipfs.goOffline(resolve))
|
||||
// },
|
||||
{
|
||||
// js-ipfs-api via local daemon
|
||||
start: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
OrbitServer.start();
|
||||
ipfsd.disposableApi((err, ipfs) => {
|
||||
if(err) reject(err);
|
||||
if(err) console.error(err);
|
||||
resolve(ipfs);
|
||||
});
|
||||
// ipfsd.local(ipfsPath, (err, node) => {
|
||||
// ipfsd.local((err, node) => {
|
||||
// if(err) reject(err);
|
||||
// node.startDaemon((err, ipfs) => {
|
||||
// ipfsDaemon = node;
|
||||
// ipfsDaemon.startDaemon((err, ipfs) => {
|
||||
// if(err) reject(err);
|
||||
// resolve(ipfs);
|
||||
// });
|
||||
// });
|
||||
});
|
||||
};
|
||||
},
|
||||
stop: () => Promise.resolve()
|
||||
// stop: () => new Promise((resolve, reject) => ipfsDaemon.stopDaemon(resolve))
|
||||
}
|
||||
];
|
||||
|
||||
// OrbitServer.start(); // uncomment if running this test suite stand-alone
|
||||
IpfsApis.forEach(function(ipfsApi) {
|
||||
|
||||
describe('CounterStore', function() {
|
||||
this.timeout(20000);
|
||||
|
||||
let ipfs, client1, client2;
|
||||
this.timeout(40000);
|
||||
let client1, client2;
|
||||
|
||||
before((done) => {
|
||||
rimraf.sync('./orbit-db-cache.json')
|
||||
startIpfs()
|
||||
.then((ipfs) => {
|
||||
return ipfs.add(path.resolve(process.cwd(), './test/network.json')).then(() => ipfs)
|
||||
})
|
||||
ipfsApi.start()
|
||||
// .then((ipfs) => {
|
||||
// return ipfs.add(path.resolve(process.cwd(), './test/network.json')).then(() => ipfs)
|
||||
// })
|
||||
.then((res) => {
|
||||
ipfs = res;
|
||||
return Promise.map([username, username2], (login) => {
|
||||
@ -65,8 +86,10 @@ describe('CounterStore', function() {
|
||||
after((done) => {
|
||||
if(client1) client1.disconnect();
|
||||
if(client2) client2.disconnect();
|
||||
ipfsApi.stop().then(() => {
|
||||
rimraf('./orbit-db-cache.json', done)
|
||||
});
|
||||
});
|
||||
|
||||
describe('counters', function() {
|
||||
it('increases a counter value', (done) => {
|
||||
@ -121,5 +144,6 @@ describe('CounterStore', function() {
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user