Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

chore: peer-discovery not using peer-info #90

Merged
merged 4 commits into from
Apr 23, 2020

Conversation

vasco-santos
Copy link
Member

@vasco-santos vasco-santos commented Apr 6, 2020

In the context of deprecating peer-info as described on libp2p/js-libp2p#589, this PR changes the peer-discovery interface to emit an object containing an id property and a multiaddrs property.

This adds a multiaddrs property to the constructor for now. This should receive libp2p and access the libp2p listening multiaddrs instead

BREAKING CHANGE: peer event emits an object with id and multiaddr instead of a peer-info

Needs:

BREAKING CHANGE: peer event emitted with id and multiaddrs properties instead of peer-info
@vasco-santos vasco-santos force-pushed the chore/peer-discovery-not-using-peer-info branch from adf6788 to 5c6daaf Compare April 16, 2020 15:48
@vasco-santos vasco-santos marked this pull request as ready for review April 17, 2020 16:08
@vasco-santos vasco-santos requested a review from jacobheun April 17, 2020 16:13
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.

Some minor things

src/compat/index.js Outdated Show resolved Hide resolved
src/compat/responder.js Outdated Show resolved Hide resolved
this._queryInterval = null
this._onPeer = this._onPeer.bind(this)

if (options.compat !== false) {
this._goMdns = new GoMulticastDNS(options.peerInfo, {
this._goMdns = new GoMulticastDNS(options.peerId, this.peerMultiaddrs, {
queryPeriod: options.compatQueryPeriod,
queryInterval: options.compatQueryInterval
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Existing bug, we're apparently not passing these options into the querier GoMulticastDNS creates. It's constructor doesn't take options but it should

Copy link
Member Author

Choose a reason for hiding this comment

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

I will fix this

}

this.broadcast = options.broadcast !== false
this.interval = options.interval || (1e3 * 10)
this.serviceTag = options.serviceTag || 'ipfs.local'
this.port = options.port || 5353
this.peerInfo = options.peerInfo
this.peerId = options.peerId
this.peerMultiaddrs = options.multiaddrs || []
this._queryInterval = null
this._onPeer = this._onPeer.bind(this)
Copy link
Contributor

Choose a reason for hiding this comment

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

This function needs to be fixed. It still takes and emits peerInfo. Recommend doing a project case insensitive search for peerinfo to catch any other items.

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably just needs a rename to peerData to avoid confusion

src/index.js Outdated
}

async _onMdnsResponse (event) {
try {
const foundPeer = await query.gotResponse(event, this.peerInfo, this.serviceTag)
const foundPeer = await query.gotResponse(event, this.peerId, this.serviceTag)
Copy link
Contributor

Choose a reason for hiding this comment

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

gotResponse is not async anymore, don't await.

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
@vasco-santos vasco-santos force-pushed the chore/peer-discovery-not-using-peer-info branch from 03d68a6 to 2b52761 Compare April 21, 2020 11:02
@vasco-santos
Copy link
Member Author

vasco-santos commented Apr 21, 2020

I addressed the review and also fixed the Querier parameters bug

@vasco-santos vasco-santos requested a review from jacobheun April 21, 2020 11:38
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, but the readme needs to be updated, the usage is wrong now.

@vasco-santos
Copy link
Member Author

Changed README to use peerData instead of peerInfo for events and peerId instead of peerInfo for the MDNS constructor. It should all correct now

@jacobheun jacobheun merged commit fca175e into master Apr 23, 2020
@jacobheun jacobheun deleted the chore/peer-discovery-not-using-peer-info branch April 23, 2020 12:05
@jacobheun
Copy link
Contributor

Beta tag released:

dist-tags:
beta: 0.14.0    latest: 0.13.3  

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants