-
Notifications
You must be signed in to change notification settings - Fork 471
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/discovery-mechanisms #498
refactor: examples/discovery-mechanisms #498
Conversation
1f004e3
to
07f0e97
Compare
374ceb4
to
45f4702
Compare
07f0e97
to
cc46973
Compare
cc46973
to
980ae89
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor things, otherwise it looks good. I ran it without any issues.
}, | ||
config: { | ||
peerDiscovery: { | ||
bootstrap: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be the mdns config, it's using bootstrap.
// picking any protocol) in order to get a full Connection. The Peer Discovery | ||
// doesn't make any decisions for you. | ||
node.dial(peer, () => {}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
autoDial is true by default, we should remove this block.
}) | ||
node.start(cb) | ||
const peerInfo = await PeerInfo.create() | ||
peerInfo.multiaddrs.add('/ip4/0.0.0.0/tcp/0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could let Libp2p.create
create the PeerInfo and then just do libp2p.peerInfo.multiaddrs.add('/ip4/0.0.0.0/tcp/0')
after we create the node.
examples/discovery-mechanisms/1.js
Outdated
} | ||
;(async () => { | ||
const peerInfo = await PeerInfo.create() | ||
peerInfo.multiaddrs.add('/ip4/0.0.0.0/tcp/0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here as below, let Libp2p.create
make the PeerInfo
.
8b729b5
to
609bd10
Compare
Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
609bd10
to
0535ecf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two minor things, otherwise this looks good.
// Once the dial is complete, this event is emitted. | ||
node.on('peer:connect', (peer) => { | ||
console.log('Connection established to:', peer.id.toB58String()) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add the peer:connect
event listener back, I think it got accidentally removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought you suggested to remove it because of being kind of redundant, since should dial is true by default libp2p/js-libp2p#498/files#r358312128. But yeah, let's put it back, I also think we can double check this
Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* refactor: examples-discovery-mechanisms * chore: apply suggestions from code review Co-Authored-By: Jacob Heun <jacobheun@gmail.com> * chore: suggestion interval Co-Authored-By: Jacob Heun <jacobheun@gmail.com> * chore: add peer connected event Co-authored-by: Jacob Heun <jacobheun@gmail.com>
This PR refactors the
discovery-mechanisms
example to the refactored asyncjs-libp2p
.Needs: