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

fix: clean up peer discovery flow #494

Merged
merged 3 commits into from
Dec 3, 2019
Merged

Conversation

jacobheun
Copy link
Contributor

  • peerStore.update no longer replaces existing protocols and multiaddrs, this is inline with PeerBook.
  • Identify will now call peerStore.replace() instead of peerStore.update(). As we are talking directly with the target peer, we should consider them the source of truth. With Multiaddr confidence in the future and PeerStore v2, this may may change.
  • All PeerDiscovery peer events will now be directed to the peerStore directly.
  • peer:discovery events are now being Proxied from the PeerStore. This also ensures we won't discover a peer twice.
  • PeerStore.replace() will always trigger change:multiaddrs and change:protocols events. This is an oversimplification and may not indicate an actual change, but this is probably better reserved for PeerStore v2 work.

@@ -217,6 +206,16 @@ class PeerStore extends EventEmitter {

this.remove(peerInfo.id.toB58String())
this.add(peerInfo)

// This should be cleaned up in PeerStore v2
this.emit('change:multiaddrs', {
Copy link
Member

Choose a reason for hiding this comment

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

the multiaddrs may not change, right?

Copy link
Member

@vasco-santos vasco-santos 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 17b4af7 into refactor/async-await Dec 3, 2019
@jacobheun jacobheun deleted the fix/peer-disco branch December 3, 2019 19:14
jacobheun added a commit that referenced this pull request Dec 12, 2019
* fix: clean up peer discovery flow

* test(fix): let libp2p start after connecting

* test(fix): dont auto dial in disco tests
jacobheun added a commit that referenced this pull request Jan 24, 2020
* fix: clean up peer discovery flow

* test(fix): let libp2p start after connecting

* test(fix): dont auto dial in disco tests
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