Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: examples/pnet #523

Merged
merged 3 commits into from
Jan 7, 2020
Merged

Conversation

vasco-santos
Copy link
Member

This PR refactors the pnet example to the refactored async js-libp2p. Moreover, it now does not use ipfs and relies only on libp2p

@vasco-santos vasco-santos changed the base branch from master to refactor/async-await December 19, 2019 18:10
;(async () => {
const node1 = await privateLibp2pNode(swarmKey)
const node2 = await privateLibp2pNode(swarmKey)
// const node2 = await privateLibp2pNode(otherSwarmKey)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacobheun I am having an issue using a invalid key.

On the transport listener, for example libp2p-tcp https://github.com/libp2p/js-libp2p-tcp/blob/master/src/listener.js#L23 the upgradeInbound throws and the promise rejection is not handled. What do you recommend to do here? A try...catch in the encrypt and just log the error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vasco-santos the upgradeInbound should probably still throw. The Transport needs to know that there has been a failure so that it doesn't do any emitting. I think the best thing to do is to make sure that the transport listeners are catching that and logging errors. We should add a test for this to the transport interface and roll out patches to each of the transports.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I agree that should be the transports to handle this. Will PR everything

const swarmKey1Path = path.resolve(repo1, 'swarm.key')
const swarmKey2Path = path.resolve(repo2, 'swarm.key')
fs.writeFileSync(swarmKey1Path, swarmKey)
// TASK: switch the commented out line below so we're using a different key, to see the nodes fail to connect
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README mentions the TASK comments in the code for trying out the different swarm keys. How this is being done has changed, can we add a TASK comment for replacing const node2 = await privateLibp2pNode(swarmKey) with const node2 = await privateLibp2pNode(otherSwarmKey). The code is there, there's just no comment saying to do this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

Copy link
Contributor

@jacobheun jacobheun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

@jacobheun jacobheun merged commit 0840739 into refactor/async-await Jan 7, 2020
@jacobheun jacobheun deleted the refactor/examples-pnet branch January 7, 2020 13:53
jacobheun pushed a commit that referenced this pull request Jan 24, 2020
* refactor: examples/pnet

* chore: rename pnet-ipfs to pnet

* chore: address review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants