mirror of
				https://github.com/orbitdb/orbitdb.git
				synced 2025-10-07 22:57:07 +00:00 
			
		
		
		
	Fix examples
This commit is contained in:
		
							parent
							
								
									4cfd5367db
								
							
						
					
					
						commit
						d26c19adf4
					
				
							
								
								
									
										34966
									
								
								dist/orbitdb.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										34966
									
								
								dist/orbitdb.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -32,7 +32,7 @@ try { | |||||||
|           logger.debug(`${key} | ${result}`); |           logger.debug(`${key} | ${result}`); | ||||||
|           logger.debug("---------------------------------------------------") |           logger.debug("---------------------------------------------------") | ||||||
|           console.log('\n'); |           console.log('\n'); | ||||||
|         }).catch((e) => logger.error(e)); |         }).catch((e) => logger.error(e.stack)); | ||||||
|       }; |       }; | ||||||
|       setInterval(query, 1000); |       setInterval(query, 1000); | ||||||
|     }); |     }); | ||||||
|  | |||||||
| @ -171665,7 +171665,7 @@ | |||||||
| 	      if (!ipfs) throw new Error("Ipfs instance not defined"); | 	      if (!ipfs) throw new Error("Ipfs instance not defined"); | ||||||
| 	      if (!hash) throw new Error("Invalid hash: " + hash); | 	      if (!hash) throw new Error("Invalid hash: " + hash); | ||||||
| 	      return ipfs.object.get(hash, { enc: 'base58' }).then(function (res) { | 	      return ipfs.object.get(hash, { enc: 'base58' }).then(function (res) { | ||||||
| 	        console.log("RES", res); | 	        // console.log("RES", res)
 | ||||||
| 	        return Log.fromJson(ipfs, JSON.parse(res.toJSON().Data)); | 	        return Log.fromJson(ipfs, JSON.parse(res.toJSON().Data)); | ||||||
| 	      }); | 	      }); | ||||||
| 	    } | 	    } | ||||||
| @ -171772,9 +171772,16 @@ | |||||||
| 	    value: function fromIpfsHash(ipfs, hash) { | 	    value: function fromIpfsHash(ipfs, hash) { | ||||||
| 	      if (!ipfs) throw new Error("Node requires ipfs instance"); | 	      if (!ipfs) throw new Error("Node requires ipfs instance"); | ||||||
| 	      if (!hash) throw new Error("Invalid hash: " + hash); | 	      if (!hash) throw new Error("Invalid hash: " + hash); | ||||||
| 	      console.log(hash); |  | ||||||
| 	      return ipfs.object.get(hash, { enc: 'base58' }).then(function (obj) { | 	      return ipfs.object.get(hash, { enc: 'base58' }).then(function (obj) { | ||||||
| 	        var f = JSON.parse(obj.toJSON().Data); | 	        var f = void 0; | ||||||
|  | 	        try { | ||||||
|  | 	          f = JSON.parse(obj.toJSON().Data); | ||||||
|  | 	        } catch (e) { | ||||||
|  | 	          console.log("--------------"); | ||||||
|  | 	          console.log(e); | ||||||
|  | 	          console.log(obj.toJSON()); | ||||||
|  | 	        } | ||||||
|  | 	        // const f = JSON.parse(obj.toJSON().Data)
 | ||||||
| 	        return Node.create(ipfs, f.payload, f.next); | 	        return Node.create(ipfs, f.payload, f.next); | ||||||
| 	      }); | 	      }); | ||||||
| 	    } | 	    } | ||||||
| @ -171838,7 +171845,7 @@ | |||||||
| 	          logger.debug("---------------------------------------------------"); | 	          logger.debug("---------------------------------------------------"); | ||||||
| 	          console.log('\n'); | 	          console.log('\n'); | ||||||
| 	        }).catch(function (e) { | 	        }).catch(function (e) { | ||||||
| 	          return logger.error(e); | 	          return logger.error(e.stack); | ||||||
| 	        }); | 	        }); | ||||||
| 	      }; | 	      }; | ||||||
| 	      setInterval(query, 1000); | 	      setInterval(query, 1000); | ||||||
|  | |||||||
| @ -2,7 +2,8 @@ | |||||||
| 
 | 
 | ||||||
| const async   = require('asyncawait/async'); | const async   = require('asyncawait/async'); | ||||||
| const await   = require('asyncawait/await'); | const await   = require('asyncawait/await'); | ||||||
| const ipfsd   = require('ipfsd-ctl'); | const IPFS = require('ipfs') | ||||||
|  | // const ipfsd   = require('ipfsd-ctl');
 | ||||||
| const OrbitDB = require('../src/OrbitDB'); | const OrbitDB = require('../src/OrbitDB'); | ||||||
| const Timer   = require('./Timer'); | const Timer   = require('./Timer'); | ||||||
| 
 | 
 | ||||||
| @ -16,10 +17,14 @@ const channelName = process.argv[3] ? process.argv[3] : 'c1'; | |||||||
| 
 | 
 | ||||||
| const startIpfs = () => { | const startIpfs = () => { | ||||||
|   return new Promise((resolve, reject) => { |   return new Promise((resolve, reject) => { | ||||||
|     ipfsd.disposableApi((err, ipfs) => { |     // ipfsd.disposableApi((err, ipfs) => {
 | ||||||
|       if(err) console.error(err); |     //   if(err) console.error(err);
 | ||||||
|       resolve(ipfs); |     //   resolve(ipfs);
 | ||||||
|     }); |     // });
 | ||||||
|  |     const ipfs = new IPFS() | ||||||
|  |     ipfs.goOnline(() => { | ||||||
|  |       resolve(ipfs) | ||||||
|  |     }) | ||||||
|   }); |   }); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -6,10 +6,12 @@ const path    = require('path'); | |||||||
| const assert  = require('assert'); | const assert  = require('assert'); | ||||||
| const async   = require('asyncawait/async'); | const async   = require('asyncawait/async'); | ||||||
| const await   = require('asyncawait/await'); | const await   = require('asyncawait/await'); | ||||||
| const ipfsd   = require('ipfsd-ctl'); | // const ipfsd   = require('ipfsd-ctl');
 | ||||||
| const OrbitDB = require('../src/OrbitDB'); | const OrbitDB = require('../src/OrbitDB'); | ||||||
| const OrbitServer = require('orbit-server/src/server'); | const OrbitServer = require('orbit-server/src/server'); | ||||||
| 
 | 
 | ||||||
|  | const IPFS = require('ipfs') | ||||||
|  | 
 | ||||||
| // Mute logging
 | // Mute logging
 | ||||||
| // require('logplease').setLogLevel('ERROR');
 | // require('logplease').setLogLevel('ERROR');
 | ||||||
| 
 | 
 | ||||||
| @ -21,10 +23,10 @@ const password = ''; | |||||||
| const startIpfs = () => { | const startIpfs = () => { | ||||||
|   return new Promise((resolve, reject) => { |   return new Promise((resolve, reject) => { | ||||||
|     // OrbitServer.start();
 |     // OrbitServer.start();
 | ||||||
|     ipfsd.disposableApi((err, ipfs) => { |     // ipfsd.disposableApi((err, ipfs) => {
 | ||||||
|       if(err) console.error(err); |     //   if(err) console.error(err);
 | ||||||
|       resolve(ipfs); |     //   resolve(ipfs);
 | ||||||
|     }); |     // });
 | ||||||
|     // ipfsd.local((err, node) => {
 |     // ipfsd.local((err, node) => {
 | ||||||
|     //   if(err) reject(err);
 |     //   if(err) reject(err);
 | ||||||
|     //   node.startDaemon((err, ipfs) => {
 |     //   node.startDaemon((err, ipfs) => {
 | ||||||
| @ -32,6 +34,10 @@ const startIpfs = () => { | |||||||
|     //     resolve(ipfs);
 |     //     resolve(ipfs);
 | ||||||
|     //   });
 |     //   });
 | ||||||
|     // });
 |     // });
 | ||||||
|  |     const ipfs = new IPFS(); | ||||||
|  |     ipfs.goOnline(() => { | ||||||
|  |       resolve(ipfs) | ||||||
|  |     }) | ||||||
|   }); |   }); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| @ -49,8 +55,8 @@ describe('Orbit Client', function() { | |||||||
|       ipfs = await(startIpfs()); |       ipfs = await(startIpfs()); | ||||||
|       // const str = fs.readFileSync('./test/network.json', 'utf-8');
 |       // const str = fs.readFileSync('./test/network.json', 'utf-8');
 | ||||||
|       // const networkData = new Buffer(JSON.stringify({ Data: str }));
 |       // const networkData = new Buffer(JSON.stringify({ Data: str }));
 | ||||||
|       const networkFile = await(ipfs.add(path.resolve(process.cwd(), './test/network.json'))); |       // const networkFile = await(ipfs.add(path.resolve(process.cwd(), './test/network.json')));
 | ||||||
|       assert.equal(networkFile[0].Hash, network); |       // assert.equal(networkFile[0].Hash, network);
 | ||||||
|       client = await(OrbitDB.connect(network, username, password, ipfs, { allowOffline: true })); |       client = await(OrbitDB.connect(network, username, password, ipfs, { allowOffline: true })); | ||||||
|       client2 = await(OrbitDB.connect(network, username + "2", password, ipfs, { allowOffline: true })); |       client2 = await(OrbitDB.connect(network, username + "2", password, ipfs, { allowOffline: true })); | ||||||
|     } catch(e) { |     } catch(e) { | ||||||
| @ -64,6 +70,7 @@ describe('Orbit Client', function() { | |||||||
|   after(() => { |   after(() => { | ||||||
|     if(db) db.delete(); |     if(db) db.delete(); | ||||||
|     if(client) client.disconnect(); |     if(client) client.disconnect(); | ||||||
|  |     if(ipfs) ipfs.goOffline(); | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
| /* | /* | ||||||
|  | |||||||
| @ -5,9 +5,10 @@ const path        = require('path'); | |||||||
| const fs          = require('fs'); | const fs          = require('fs'); | ||||||
| const Promise     = require('bluebird'); | const Promise     = require('bluebird'); | ||||||
| const rimraf      = require('rimraf') | const rimraf      = require('rimraf') | ||||||
| const ipfsd       = require('ipfsd-ctl'); | // const ipfsd       = require('ipfsd-ctl');
 | ||||||
| const OrbitDB     = require('../src/OrbitDB'); | const OrbitDB     = require('../src/OrbitDB'); | ||||||
| const OrbitServer = require('orbit-server/src/server'); | const OrbitServer = require('orbit-server/src/server'); | ||||||
|  | const IPFS = require('ipfs') | ||||||
| 
 | 
 | ||||||
| // Mute logging
 | // Mute logging
 | ||||||
| require('logplease').setLogLevel('ERROR'); | require('logplease').setLogLevel('ERROR'); | ||||||
| @ -21,10 +22,10 @@ const ipfsPath = '/tmp/orbittests'; | |||||||
| const startIpfs = () => { | const startIpfs = () => { | ||||||
|   return new Promise((resolve, reject) => { |   return new Promise((resolve, reject) => { | ||||||
|     OrbitServer.start(); |     OrbitServer.start(); | ||||||
|     ipfsd.disposableApi((err, ipfs) => { |     // ipfsd.disposableApi((err, ipfs) => {
 | ||||||
|       if(err) reject(err); |     //   if(err) reject(err);
 | ||||||
|       resolve(ipfs); |     //   resolve(ipfs);
 | ||||||
|     }); |     // });
 | ||||||
|     // ipfsd.local(ipfsPath, (err, node) => {
 |     // ipfsd.local(ipfsPath, (err, node) => {
 | ||||||
|     //   if(err) reject(err);
 |     //   if(err) reject(err);
 | ||||||
|     //   node.startDaemon((err, ipfs) => {
 |     //   node.startDaemon((err, ipfs) => {
 | ||||||
| @ -32,6 +33,10 @@ const startIpfs = () => { | |||||||
|     //     resolve(ipfs);
 |     //     resolve(ipfs);
 | ||||||
|     //   });
 |     //   });
 | ||||||
|     // });
 |     // });
 | ||||||
|  |     const ipfs = new IPFS(); | ||||||
|  |     ipfs.goOnline(() => { | ||||||
|  |       resolve(ipfs) | ||||||
|  |     }) | ||||||
|   }); |   }); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| @ -43,9 +48,9 @@ describe('CounterStore', function() { | |||||||
|   before((done) => { |   before((done) => { | ||||||
|     rimraf.sync('./orbit-db-cache.json') |     rimraf.sync('./orbit-db-cache.json') | ||||||
|     startIpfs() |     startIpfs() | ||||||
|       .then((ipfs) => { |       // .then((ipfs) => {
 | ||||||
|         return ipfs.add(path.resolve(process.cwd(), './test/network.json')).then(() => ipfs) |       //   return ipfs.add(path.resolve(process.cwd(), './test/network.json')).then(() => ipfs)
 | ||||||
|       }) |       // })
 | ||||||
|       .then((res) => { |       .then((res) => { | ||||||
|         ipfs = res; |         ipfs = res; | ||||||
|         return Promise.map([username, username2], (login) => { |         return Promise.map([username, username2], (login) => { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 haad
						haad