Browse Source

Orbit hotfix

develop
Ezerous 6 years ago
parent
commit
a88abe61dd
  1. 16
      app/src/orbit.js

16
app/src/orbit.js

@ -6,7 +6,7 @@ import store from './redux/store';
import ipfsOptions from './config/ipfsOptions' import ipfsOptions from './config/ipfsOptions'
import { IPFS_INITIALIZED, DATABASES_CREATED, DATABASES_LOADED } from './redux/actions/orbitActions'; import { IPFS_INITIALIZED, DATABASES_CREATED, DATABASES_LOADED } from './redux/actions/orbitActions';
let ipfs, orbitdb, topicsDB, postsDB; let ipfs;
function initIPFS(){ function initIPFS(){
ipfs = new IPFS(ipfsOptions); ipfs = new IPFS(ipfsOptions);
@ -17,9 +17,9 @@ function initIPFS(){
async function createDatabases() { async function createDatabases() {
console.log("Creating databases..."); console.log("Creating databases...");
orbitdb = await new OrbitDB(ipfs); const orbitdb = await new OrbitDB(ipfs);
topicsDB = await orbitdb.keyvalue('topics'); const topicsDB = await orbitdb.keyvalue('topics');
postsDB = await orbitdb.keyvalue('posts'); const postsDB = await orbitdb.keyvalue('posts');
store.dispatch({ store.dispatch({
type: DATABASES_CREATED, type: DATABASES_CREATED,
orbitdb: orbitdb, orbitdb: orbitdb,
@ -43,7 +43,7 @@ async function createDatabases() {
} }
async function loadDatabases(identityId, identityPublicKey, identityPrivateKey, async function loadDatabases(identityId, identityPublicKey, identityPrivateKey,
orbitId, orbitPublicKey, orbitPrivateKey, topicsDB, postsDB) { orbitId, orbitPublicKey, orbitPrivateKey, topicsDBId, postsDBId) {
console.log("Loading databases..."); console.log("Loading databases...");
let directory = "./orbitdb"; let directory = "./orbitdb";
let keystore = Keystore.create(path.join(directory, orbitId, '/keystore')); let keystore = Keystore.create(path.join(directory, orbitId, '/keystore'));
@ -53,9 +53,9 @@ async function loadDatabases(identityId, identityPublicKey, identityPrivateKey,
privateKey: orbitPrivateKey privateKey: orbitPrivateKey
})); }));
orbitdb = await new OrbitDB(ipfs, directory, { peerId:orbitId, keystore:keystore}); const orbitdb = await new OrbitDB(ipfs, directory, { peerId:orbitId, keystore:keystore});
topicsDB = await orbitdb.keyvalue('/orbitdb/' + topicsDB +'/topics'); const topicsDB = await orbitdb.keyvalue('/orbitdb/' + topicsDBId +'/topics');
postsDB = await orbitdb.keyvalue('/orbitdb/' + postsDB +'/posts'); const postsDB = await orbitdb.keyvalue('/orbitdb/' + postsDBId +'/posts');
await topicsDB.load(); await topicsDB.load();
await postsDB.load(); await postsDB.load();

Loading…
Cancel
Save