mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-06-27 00:12:29 +00:00
ipfs.cat the network info
This commit is contained in:
parent
e1573a476b
commit
1f0fb823f4
@ -111,17 +111,20 @@ 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));
|
||||
resolve(JSON.stringify({
|
||||
name: 'localhost dev network',
|
||||
publishers: ['localhost:3333']
|
||||
}))
|
||||
this._ipfs.files.cat(hash, (err, res) => {
|
||||
if(err) return reject(e)
|
||||
let buf = '';
|
||||
res.on('data', (res) => {
|
||||
res.stream
|
||||
.on('error', (err) => reject(err))
|
||||
.on('data', (data) => buf += data)
|
||||
.on('end', () => resolve(buf.toString()))
|
||||
})
|
||||
});
|
||||
// resolve(JSON.stringify({
|
||||
// name: 'localhost dev network',
|
||||
// publishers: ['localhost:3333']
|
||||
// }))
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -21,41 +21,42 @@ const password = '';
|
||||
|
||||
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
|
||||
// js-ipfs
|
||||
start: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
ipfsd.disposableApi((err, ipfs) => {
|
||||
if(err) console.error(err);
|
||||
resolve(ipfs);
|
||||
const IPFS = require('ipfs')
|
||||
const ipfs = new IPFS();
|
||||
ipfs.goOnline((err) => {
|
||||
if(err) reject(err)
|
||||
resolve(ipfs)
|
||||
});
|
||||
// ipfsd.local((err, node) => {
|
||||
// if(err) reject(err);
|
||||
// ipfsDaemon = node;
|
||||
// ipfsDaemon.startDaemon((err, ipfs) => {
|
||||
// if(err) reject(err);
|
||||
// resolve(ipfs);
|
||||
// });
|
||||
// });
|
||||
});
|
||||
},
|
||||
stop: () => Promise.resolve()
|
||||
// stop: () => new Promise((resolve, reject) => ipfsDaemon.stopDaemon(resolve))
|
||||
}
|
||||
// stop: () => Promise.resolve()
|
||||
stop: () => new Promise((resolve, reject) => ipfs.goOffline(resolve))
|
||||
},
|
||||
// {
|
||||
// // js-ipfs-api via local daemon
|
||||
// start: () => {
|
||||
// return new Promise((resolve, reject) => {
|
||||
// ipfsd.disposableApi((err, ipfs) => {
|
||||
// if(err) console.error(err);
|
||||
// resolve(ipfs);
|
||||
// });
|
||||
// // ipfsd.local((err, node) => {
|
||||
// // if(err) reject(err);
|
||||
// // 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();
|
||||
|
@ -20,38 +20,39 @@ const ipfsPath = '/tmp/orbittests';
|
||||
|
||||
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
|
||||
// js-ipfs
|
||||
start: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
ipfsd.disposableApi((err, ipfs) => {
|
||||
if(err) console.error(err);
|
||||
resolve(ipfs);
|
||||
});
|
||||
// ipfsd.local((err, node) => {
|
||||
// if(err) reject(err);
|
||||
// ipfsDaemon = node;
|
||||
// ipfsDaemon.startDaemon((err, ipfs) => {
|
||||
// if(err) reject(err);
|
||||
const IPFS = require('ipfs')
|
||||
const ipfs = new IPFS();
|
||||
ipfs.goOnline(() => resolve(ipfs));
|
||||
// resolve(ipfs);
|
||||
// });
|
||||
// });
|
||||
});
|
||||
},
|
||||
stop: () => Promise.resolve()
|
||||
// stop: () => new Promise((resolve, reject) => ipfsDaemon.stopDaemon(resolve))
|
||||
}
|
||||
stop: () => new Promise((resolve, reject) => ipfs.goOffline(resolve))
|
||||
},
|
||||
// {
|
||||
// // js-ipfs-api via local daemon
|
||||
// start: () => {
|
||||
// return new Promise((resolve, reject) => {
|
||||
// ipfsd.disposableApi((err, ipfs) => {
|
||||
// if(err) console.error(err);
|
||||
// resolve(ipfs);
|
||||
// });
|
||||
// // ipfsd.local((err, node) => {
|
||||
// // if(err) reject(err);
|
||||
// // 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user