Skip to content

Commit

Permalink
✨ commented out obligatory websocket connection
Browse files Browse the repository at this point in the history
  • Loading branch information
QYuQianchen committed May 14, 2019
1 parent efd7e89 commit f643454
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion applications/api/src/modules/ipfs/ipfs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class IpfsService {
// this.node.on('ready', () => {
this.node
.id()
.catch((error: any) => this.logger.log(` [ipfs module] has an error ${error}`))
.catch((error: any) => this.logger.error(` [ipfs module] has an error ${error}`))
.then((id: any) => {
this.logger.log(` [ipfs module] the id is ${id}.`);
})
Expand Down
45 changes: 23 additions & 22 deletions applications/ui/src/libs/ipfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,30 @@ export const initializeIpfs = () => {
console.log(' [ initialize ipfs ] Online status: ', node.isOnline() ? 'online' : 'offline');
node.once('ready', () => {
console.log(' [ initialize ipfs ] IPFS node is ready');
node.swarm.connect(
'/ip4/127.0.0.1/tcp/4003/ws/ipfs/QmVJQDXoLqfBpBwBVmi96zbuD3eQazQf274EEwLB6BNWaZ',
// This information is in align with the daemon. Connecting through websocket by the hash. Config could be found and set at "~/.ipfs/config"
(err: any) => {
if (err) {
throw err;
}
// if no err is present, connection is now open
console.log(' [ initialize ipfs ] Websocket connection is added');
node.id((err: any, res: any) => {
if (err) {
throw err;
}
console.log(' [ initialize ipfs ] The node identity is: ', res.id);
// node.config.get((err: any, config: any) => {
// if (err) {
// throw err;
// }
// console.log(' [ initialize ipfs ] The node config is: ', config);
// });
});
node.id((err: any, res: any) => {
if (err) {
console.error(' [initialize ipfs] id query failed', err);
throw err;
}
);
console.log(' [ initialize ipfs ] The node identity is: ', res.id);
});
// try {
// node.swarm.connect(
// '/ip4/127.0.0.1/tcp/4003/ws/ipfs/QmVJQDXoLqfBpBwBVmi96zbuD3eQazQf274EEwLB6BNWaZ'
// // // This information is in align with the daemon. Connecting through websocket by the hash. Config could be found and set at "~/.ipfs/config"
// // , (err: any, res: any) => {
// // if (err) {
// // console.error(' [initialize ipfs ] Websocket connection tempt failed', err);
// // throw err;
// // }
// // // if no err is present, connection is now open
// // console.log(' [ initialize ipfs ] Websocket connection is added', res);
// // }
// );
// } catch (e) {
// console.error(' [ initialize ipfs try] ', e);
// throw e;
// }
});
node.once('error', (error: any) => {
console.error('Something went terribly wrong!', error);
Expand Down

0 comments on commit f643454

Please sign in to comment.